cxgb4: Free Virtual Interfaces in remove routine
authorHariprasad Shenai <hariprasad@chelsio.com>
Fri, 5 Jun 2015 08:54:47 +0000 (14:24 +0530)
committerDavid S. Miller <davem@davemloft.net>
Sat, 6 Jun 2015 04:25:55 +0000 (21:25 -0700)
Free VI interfaces in remove routine. If we don't do this then the
firmware will never drop the physical link to the peer.

Signed-off-by: Hariprasad Shenai <hariprasad@chelsio.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
drivers/net/ethernet/chelsio/cxgb4/t4_hw.c

index bf2b822..93e6cbc 100644 (file)
@@ -1378,6 +1378,9 @@ int t4_cfg_pfvf(struct adapter *adap, unsigned int mbox, unsigned int pf,
 int t4_alloc_vi(struct adapter *adap, unsigned int mbox, unsigned int port,
                unsigned int pf, unsigned int vf, unsigned int nmac, u8 *mac,
                unsigned int *rss_size);
+int t4_free_vi(struct adapter *adap, unsigned int mbox,
+              unsigned int pf, unsigned int vf,
+              unsigned int viid);
 int t4_set_rxmode(struct adapter *adap, unsigned int mbox, unsigned int viid,
                int mtu, int promisc, int all_multi, int bcast, int vlanex,
                bool sleep_ok);
index 3057154..e6abdb7 100644 (file)
@@ -4538,6 +4538,11 @@ static void free_some_resources(struct adapter *adapter)
 
        for_each_port(adapter, i)
                if (adapter->port[i]) {
+                       struct port_info *pi = adap2pinfo(adapter, i);
+
+                       if (pi->viid != 0)
+                               t4_free_vi(adapter, adapter->mbox, adapter->pf,
+                                          0, pi->viid);
                        kfree(adap2pinfo(adapter, i)->rss);
                        free_netdev(adapter->port[i]);
                }
index c21ab26..3a56254 100644 (file)
@@ -5226,6 +5226,33 @@ int t4_alloc_vi(struct adapter *adap, unsigned int mbox, unsigned int port,
 }
 
 /**
+ *     t4_free_vi - free a virtual interface
+ *     @adap: the adapter
+ *     @mbox: mailbox to use for the FW command
+ *     @pf: the PF owning the VI
+ *     @vf: the VF owning the VI
+ *     @viid: virtual interface identifiler
+ *
+ *     Free a previously allocated virtual interface.
+ */
+int t4_free_vi(struct adapter *adap, unsigned int mbox, unsigned int pf,
+              unsigned int vf, unsigned int viid)
+{
+       struct fw_vi_cmd c;
+
+       memset(&c, 0, sizeof(c));
+       c.op_to_vfn = cpu_to_be32(FW_CMD_OP_V(FW_VI_CMD) |
+                                 FW_CMD_REQUEST_F |
+                                 FW_CMD_EXEC_F |
+                                 FW_VI_CMD_PFN_V(pf) |
+                                 FW_VI_CMD_VFN_V(vf));
+       c.alloc_to_len16 = cpu_to_be32(FW_VI_CMD_FREE_F | FW_LEN16(c));
+       c.type_viid = cpu_to_be16(FW_VI_CMD_VIID_V(viid));
+
+       return t4_wr_mbox(adap, mbox, &c, sizeof(c), &c);
+}
+
+/**
  *     t4_set_rxmode - set Rx properties of a virtual interface
  *     @adap: the adapter
  *     @mbox: mailbox to use for the FW command