]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
net: netcp: add api to support set rx mode in netcp modules
authorWingMan Kwok <w-kwok2@ti.com>
Tue, 17 Apr 2018 21:30:41 +0000 (17:30 -0400)
committerDavid S. Miller <davem@davemloft.net>
Thu, 19 Apr 2018 01:00:57 +0000 (21:00 -0400)
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>
drivers/net/ethernet/ti/netcp.h
drivers/net/ethernet/ti/netcp_core.c

index 416f732a00f78610babbdfc968b2ef5c9a604979..c4ffdf47bad56c2df0a091850ab7d6f979c88ee4 100644 (file)
@@ -214,6 +214,7 @@ struct netcp_module {
        int     (*add_vid)(void *intf_priv, int vid);
        int     (*del_vid)(void *intf_priv, int vid);
        int     (*ioctl)(void *intf_priv, struct ifreq *req, int cmd);
+       int     (*set_rx_mode)(void *intf_priv, bool promisc);
 
        /* used internally */
        struct list_head        module_list;
index 736f6f713c093a1479eeafc48e0057c7a5d55c60..e40aa3e31af2345489a4dbc896593c7dc0f574cd 100644 (file)
@@ -1509,6 +1509,24 @@ static void netcp_addr_sweep_add(struct netcp_intf *netcp)
        }
 }
 
+static int netcp_set_promiscuous(struct netcp_intf *netcp, bool promisc)
+{
+       struct netcp_intf_modpriv *priv;
+       struct netcp_module *module;
+       int error;
+
+       for_each_module(netcp, priv) {
+               module = priv->netcp_module;
+               if (!module->set_rx_mode)
+                       continue;
+
+               error = module->set_rx_mode(priv->module_priv, promisc);
+               if (error)
+                       return error;
+       }
+       return 0;
+}
+
 static void netcp_set_rx_mode(struct net_device *ndev)
 {
        struct netcp_intf *netcp = netdev_priv(ndev);
@@ -1538,6 +1556,7 @@ static void netcp_set_rx_mode(struct net_device *ndev)
        /* finally sweep and callout into modules */
        netcp_addr_sweep_del(netcp);
        netcp_addr_sweep_add(netcp);
+       netcp_set_promiscuous(netcp, promisc);
        spin_unlock(&netcp->lock);
 }