Skip to content

Commit 0542a87

Browse files
wingmankwokdavem330
authored andcommitted
net: netcp: add api to support set rx mode in netcp modules
This patch adds an API to support setting rx mode in netcp modules. If a netcp module needs to be notified when upper layer transitions from one rx mode to another and react accordingly, such a module will implement the new API set_rx_mode added in this patch. Currently rx modes supported are PROMISCUOUS and NON_PROMISCUOUS modes. Signed-off-by: WingMan Kwok <w-kwok2@ti.com> Signed-off-by: Murali Karicheri <m-karicheri2@ti.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 21f706b commit 0542a87

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

drivers/net/ethernet/ti/netcp.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ struct netcp_module {
214214
int (*add_vid)(void *intf_priv, int vid);
215215
int (*del_vid)(void *intf_priv, int vid);
216216
int (*ioctl)(void *intf_priv, struct ifreq *req, int cmd);
217+
int (*set_rx_mode)(void *intf_priv, bool promisc);
217218

218219
/* used internally */
219220
struct list_head module_list;

drivers/net/ethernet/ti/netcp_core.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1509,6 +1509,24 @@ static void netcp_addr_sweep_add(struct netcp_intf *netcp)
15091509
}
15101510
}
15111511

1512+
static int netcp_set_promiscuous(struct netcp_intf *netcp, bool promisc)
1513+
{
1514+
struct netcp_intf_modpriv *priv;
1515+
struct netcp_module *module;
1516+
int error;
1517+
1518+
for_each_module(netcp, priv) {
1519+
module = priv->netcp_module;
1520+
if (!module->set_rx_mode)
1521+
continue;
1522+
1523+
error = module->set_rx_mode(priv->module_priv, promisc);
1524+
if (error)
1525+
return error;
1526+
}
1527+
return 0;
1528+
}
1529+
15121530
static void netcp_set_rx_mode(struct net_device *ndev)
15131531
{
15141532
struct netcp_intf *netcp = netdev_priv(ndev);
@@ -1538,6 +1556,7 @@ static void netcp_set_rx_mode(struct net_device *ndev)
15381556
/* finally sweep and callout into modules */
15391557
netcp_addr_sweep_del(netcp);
15401558
netcp_addr_sweep_add(netcp);
1559+
netcp_set_promiscuous(netcp, promisc);
15411560
spin_unlock(&netcp->lock);
15421561
}
15431562

0 commit comments

Comments
 (0)