i40evf: Add driver support for promiscuous mode
authorAnjali Singhai Jain <anjali.singhai@intel.com>
Tue, 12 Apr 2016 15:30:52 +0000 (08:30 -0700)
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>
Wed, 27 Apr 2016 20:06:01 +0000 (13:06 -0700)
Add necessary Linux Ethernet driver support for promiscuous mode
operation. Add a flag so the VF knows it is in promiscuous mode
and two state flags to discreetly track multicast and unicast
promiscuous states.

Change-Id: Ib2f2dc7a7582304fec90fc917ebb7ded21ba1de4
Signed-off-by: Anjali Singhai Jain <anjali.singhai@intel.com>
Signed-off-by: Greg Rose <gregory.v.rose@intel.com>
Signed-off-by: Jesse Brandeburg <jesse.brandeburg@intel.com>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
drivers/net/ethernet/intel/i40evf/i40evf.h
drivers/net/ethernet/intel/i40evf/i40evf_main.c
drivers/net/ethernet/intel/i40evf/i40evf_virtchnl.c

index f47b0e8d02bb645e67a669478fb7011389ae81c5..c226c2dad2476788b1766dcd96bed311f35c2c9d 100644 (file)
@@ -1489,13 +1489,13 @@ static int i40e_vc_config_promiscuous_mode_msg(struct i40e_vf *vf,
                                                            NULL);
        } else if (i40e_getnum_vf_vsi_vlan_filters(vsi)) {
                list_for_each_entry(f, &vsi->mac_filter_list, list) {
-                       if (f->vlan >= 0 && f->vlan <= I40E_MAX_VLANID)
-                               aq_ret = i40e_aq_set_vsi_mc_promisc_on_vlan
-                                                                  (hw,
-                                                                  vsi->seid,
-                                                                  allmulti,
-                                                                  f->vlan,
-                                                                  NULL);
+                       if (f->vlan < 0 || f->vlan > I40E_MAX_VLANID)
+                               continue;
+                       aq_ret = i40e_aq_set_vsi_mc_promisc_on_vlan(hw,
+                                                                   vsi->seid,
+                                                                   allmulti,
+                                                                   f->vlan,
+                                                                   NULL);
                        aq_err = pf->hw.aq.asq_last_status;
                        if (aq_ret) {
                                dev_err(&pf->pdev->dev,
index 63f7aae2c8ceee2b7ba3f32530b05ab4bef6c8e4..25afabf999d02a41729b729b3f791821e814b4a3 100644 (file)
@@ -220,6 +220,7 @@ struct i40evf_adapter {
 #define I40EVF_FLAG_WB_ON_ITR_CAPABLE          BIT(11)
 #define I40EVF_FLAG_OUTER_UDP_CSUM_CAPABLE     BIT(12)
 #define I40EVF_FLAG_ADDR_SET_BY_PF             BIT(13)
+#define I40EVF_FLAG_PROMISC_ON                 BIT(15)
 /* duplicates for common code */
 #define I40E_FLAG_FDIR_ATR_ENABLED              0
 #define I40E_FLAG_DCB_ENABLED                   0
@@ -244,6 +245,8 @@ struct i40evf_adapter {
 #define I40EVF_FLAG_AQ_SET_HENA                        BIT(12)
 #define I40EVF_FLAG_AQ_SET_RSS_KEY             BIT(13)
 #define I40EVF_FLAG_AQ_SET_RSS_LUT             BIT(14)
+#define I40EVF_FLAG_AQ_REQUEST_PROMISC         BIT(15)
+#define I40EVF_FLAG_AQ_RELEASE_PROMISC         BIT(16)
 
        /* OS defined structs */
        struct net_device *netdev;
index af53159010ab43b7cb09cf2af08e983875cfe66c..d1c4afdd943504498fee19a99d761f30b05a7631 100644 (file)
@@ -943,6 +943,14 @@ static void i40evf_set_rx_mode(struct net_device *netdev)
 bottom_of_search_loop:
                continue;
        }
+
+       if (netdev->flags & IFF_PROMISC &&
+           !(adapter->flags & I40EVF_FLAG_PROMISC_ON))
+               adapter->aq_required |= I40EVF_FLAG_AQ_REQUEST_PROMISC;
+       else if (!(netdev->flags & IFF_PROMISC) &&
+                adapter->flags & I40EVF_FLAG_PROMISC_ON)
+               adapter->aq_required |= I40EVF_FLAG_AQ_RELEASE_PROMISC;
+
        clear_bit(__I40EVF_IN_CRITICAL_TASK, &adapter->crit_section);
 }
 
@@ -1622,6 +1630,17 @@ static void i40evf_watchdog_task(struct work_struct *work)
                goto watchdog_done;
        }
 
+       if (adapter->aq_required & I40EVF_FLAG_AQ_REQUEST_PROMISC) {
+               i40evf_set_promiscuous(adapter, I40E_FLAG_VF_UNICAST_PROMISC |
+                                      I40E_FLAG_VF_MULTICAST_PROMISC);
+               goto watchdog_done;
+       }
+
+       if (adapter->aq_required & I40EVF_FLAG_AQ_RELEASE_PROMISC) {
+               i40evf_set_promiscuous(adapter, 0);
+               goto watchdog_done;
+       }
+
        if (adapter->state == __I40EVF_RUNNING)
                i40evf_request_stats(adapter);
 watchdog_done:
index e62c56b5a14130d145a9dc09b4f2c86c27af3468..ba7fbc0608a6bb6d36dcc88a778ef9e77aa9b7a7 100644 (file)
@@ -652,6 +652,17 @@ void i40evf_set_promiscuous(struct i40evf_adapter *adapter, int flags)
                        adapter->current_op);
                return;
        }
+
+       if (flags) {
+               adapter->flags |= I40EVF_FLAG_PROMISC_ON;
+               adapter->aq_required &= ~I40EVF_FLAG_AQ_REQUEST_PROMISC;
+               dev_info(&adapter->pdev->dev, "Entering promiscuous mode\n");
+       } else {
+               adapter->flags &= ~I40EVF_FLAG_PROMISC_ON;
+               adapter->aq_required &= ~I40EVF_FLAG_AQ_RELEASE_PROMISC;
+               dev_info(&adapter->pdev->dev, "Leaving promiscuous mode\n");
+       }
+
        adapter->current_op = I40E_VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE;
        vpi.vsi_id = adapter->vsi_res->vsi_id;
        vpi.flags = flags;