cxgb4vf: a number of bug fixes
Subsystems (2)
cover cxgb4vf: a number of bug fixes
The following patch set includes a number of bug fixes for the cxgb4vf network driver. As always, please toss these in the bin if they're not right.
drivers/net/cxgb4vf/cxgb4vf_main.c | 42 ++++++++----- drivers/net/cxgb4vf/sge.c | 122 ++++++++++++++++++++++-------------- drivers/net/cxgb4vf/t4vf_common.h | 1 + drivers/net/cxgb4vf/t4vf_hw.c | 19 ++++++ 4 files changed, 122 insertions(+), 62 deletions(-)
PATCH 1/6 cxgb4vf: don't implement trivial (and incorrect) ndo_select_queue()
Don't implement (struct net_device_ops *)->ndo_select_queue() with simple call to skb_tx_hash(). This leads to non-persistent TX queue selection in the Linux dev_pick_tx() routine for TCP connections.
--- drivers/net/cxgb4vf/cxgb4vf_main.c | 14 -------------- 1 files changed, 0 insertions(+), 14 deletions(-)
drivers/net/cxgb4vf/cxgb4vf_main.c +0 -14
@@ -1103,18 +1103,6 @@ static int cxgb4vf_set_mac_addr(struct net_device *dev, void *_addr)return 0 ; } -/* -* Return a TX Queue on which to send the specified skb. -*/ -static u16 cxgb4vf_select_queue (struct net_device *dev,struct sk_buff *skb) -{ -/* -* XXX For now just use the default hash but we probably want to -* XXX look at other possibilities ... -*/ -return skb_tx_hash (dev, skb); -} -#ifdef CONFIG_NET_POLL_CONTROLLER /* * Poll all of our receive queues. This is called outside of normal interrupt
@@ -2417,7 +2405,6 @@ static const struct net_device_ops cxgb4vf_netdev_ops = { .ndo_get_stats = cxgb4vf_get_stats, .ndo_set_rx_mode = cxgb4vf_set_rxmode, .ndo_set_mac_address = cxgb4vf_set_mac_addr, - .ndo_select_queue = cxgb4vf_select_queue, .ndo_validate_addr = eth_validate_addr, .ndo_do_ioctl = cxgb4vf_do_ioctl, .ndo_change_mtu = cxgb4vf_change_mtu,
@@ -2624,7 +2611,6 @@ static int __devinit cxgb4vf_pci_probe(struct pci_dev *pdev, netdev->do_ioctl = cxgb4vf_do_ioctl; netdev->change_mtu = cxgb4vf_change_mtu; netdev->set_mac_address = cxgb4vf_set_mac_addr; - netdev->select_queue = cxgb4vf_select_queue;#ifdef CONFIG_NET_POLL_CONTROLLER netdev->poll_controller = cxgb4vf_poll_controller;#endif
Signature · 1 line
1.7.0.4
PATCH 2/6 cxgb4vf: fix bug in Generic Receive Offload
In reply to Casey LeedomFix botch in Generic Receive Offload (the Packet Gather List Total length field wasn't being initialized).
--- drivers/net/cxgb4vf/sge.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
drivers/net/cxgb4vf/sge.c +1 -0
@@ -1679,6 +1679,7 @@ int process_responses(struct sge_rspq *rspq, int budget) } len =RSPD_LEN (len); } + gl.tot_len = len;/* * Gather packet fragments.
Signature · 1 line
1.7.0.4
PATCH 3/6 cxgb4vf: fix some errors in Gather List to skb conversion
In reply to Casey LeedomThere were some errors in the way that internal Gather Lists were being translated into skb's. This also makes the VF Driver look more like the PF Driver to facilitate easier comarison.
--- drivers/net/cxgb4vf/sge.c | 121 +++++++++++++++++++++++++++----------------- 1 files changed, 74 insertions(+), 47 deletions(-)
drivers/net/cxgb4vf/sge.c +74 -47
@@ -154,13 +154,14 @@ enum {*/ RX_COPY_THRES =256 ,RX_PULL_LEN =128 , -}; -/* -* Can't define this in the above enum because PKTSHIFT isn't a constant in -* the VF Driver ... -*/ -#define RX_PKT_PULL_LEN (RX_PULL_LEN + PKTSHIFT) +/* +* Main body length for sk_buffs used for RX Ethernet packets with +* fragments. Should be >= RX_PULL_LEN but possibly bigger to give +* pskb_may_pull() some room. +*/ + RX_SKB_LEN = 512, +};/* * Software state per TX descriptor.
@@ -1355,6 +1356,67 @@ out_free: }/** +* t4vf_pktgl_to_skb - build an sk_buff from a packet gather list +* @gl: the gather list +* @skb_len: size of sk_buff main body if it carries fragments +* @pull_len: amount of data to move to the sk_buff's main body +* +* Builds an sk_buff from the given packet gather list. Returns the +* sk_buff or %NULL if sk_buff allocation failed. +*/ +struct sk_buff *t4vf_pktgl_to_skb (const struct pkt_gl *gl, +unsigned int skb_len,unsigned int pull_len) +{ +struct sk_buff *skb; +struct skb_shared_info *ssi; + +/* +* If the ingress packet is small enough, allocate an skb large enough +* for all of the data and copy it inline. Otherwise, allocate an skb +* with enough room to pull in the header and reference the rest of +* the data via the skb fragment list. +* +* Below we rely on RX_COPY_THRES being less than the smallest Rx +* buff! size, which is expected since buffers are at least +* PAGE_SIZEd. In this case packets up to RX_COPY_THRES have only one +* fragment. +*/ +if (gl->tot_len <=RX_COPY_THRES ) { +/* small packets have only one fragment */ + skb =alloc_skb (gl->tot_len,GFP_ATOMIC ); +if (unlikely (!skb)) + goto out; +__skb_put (skb, gl->tot_len); +skb_copy_to_linear_data (skb, gl->va, gl->tot_len); + }else { + skb =alloc_skb (skb_len,GFP_ATOMIC ); +if (unlikely (!skb)) + goto out; +__skb_put (skb, pull_len); +skb_copy_to_linear_data (skb, gl->va, pull_len); + + ssi =skb_shinfo (skb); + ssi->frags[0 ].page = gl->frags[0 ].page; + ssi->frags[0 ].page_offset = gl->frags[0 ].page_offset + pull_len; + ssi->frags[0 ].size = gl->frags[0 ].size - pull_len; +if (gl->nfrags >1 ) +memcpy (&ssi->frags[1 ], &gl->frags[1 ], + (gl->nfrags-1 ) *sizeof (skb_frag_t)); + ssi->nr_frags = gl->nfrags; + + skb->len = gl->tot_len; + skb->data_len = skb->len - pull_len; + skb->truesize += skb->data_len; + +/* Get a reference for the last page, we don't own it */ +get_page (gl->frags[gl->nfrags -1 ].page); + } + +out: +return skb; +} + +/** * t4vf_pktgl_free - free a packet gather list * @gl: the gather list *
@@ -1463,10 +1525,8 @@ int t4vf_ethrx_handler(struct sge_rspq *rspq, const __be64 *rsp, {struct sk_buff *skb;struct port_info *pi; -struct skb_shared_info *ssi;const struct cpl_rx_pkt *pkt = (void *)&rsp[1 ];bool csum_ok = pkt->csum_calc && !pkt->err_vec; -unsigned int len =be16_to_cpu (pkt->len); struct sge_eth_rxq *rxq = container_of(rspq, struct sge_eth_rxq, rspq);/*
@@ -1481,42 +1541,14 @@ int t4vf_ethrx_handler(struct sge_rspq *rspq, const __be64 *rsp, }/* -* If the ingress packet is small enough, allocate an skb large enough -* for all of the data and copy it inline. Otherwise, allocate an skb -* with enough room to pull in the header and reference the rest of -* the data via the skb fragment list. +* Convert the Packet Gather List into an skb. */ -if (len <=RX_COPY_THRES ) { -/* small packets have only one fragment */ - skb =alloc_skb (gl->frags[0 ].size,GFP_ATOMIC ); -if (!skb) - goto nomem; -__skb_put (skb, gl->frags[0 ].size); -skb_copy_to_linear_data (skb, gl->va, gl->frags[0 ].size); - }else { - skb =alloc_skb (RX_PKT_PULL_LEN ,GFP_ATOMIC ); -if (!skb) - goto nomem; -__skb_put (skb,RX_PKT_PULL_LEN ); -skb_copy_to_linear_data (skb, gl->va,RX_PKT_PULL_LEN ); - - ssi =skb_shinfo (skb); - ssi->frags[0 ].page = gl->frags[0 ].page; - ssi->frags[0 ].page_offset = (gl->frags[0 ].page_offset + -RX_PKT_PULL_LEN ); - ssi->frags[0 ].size = gl->frags[0 ].size -RX_PKT_PULL_LEN ; -if (gl->nfrags >1 ) -memcpy (&ssi->frags[1 ], &gl->frags[1 ], - (gl->nfrags-1 ) *sizeof (skb_frag_t)); - ssi->nr_frags = gl->nfrags; - skb->len = len +PKTSHIFT ; - skb->data_len = skb->len -RX_PKT_PULL_LEN ; - skb->truesize += skb->data_len; - -/* Get a reference for the last page, we don't own it */ -get_page (gl->frags[gl->nfrags -1 ].page); + skb =t4vf_pktgl_to_skb (gl,RX_SKB_LEN ,RX_PULL_LEN ); +if (unlikely (!skb)) { +t4vf_pktgl_free (gl); + rxq->stats.rx_drops++; +return 0 ; } -__skb_pull (skb,PKTSHIFT ); skb->protocol =eth_type_trans (skb, rspq->netdev);skb_record_rx_queue (skb, rspq->idx);
@@ -1549,11 +1581,6 @@ int t4vf_ethrx_handler(struct sge_rspq *rspq, const __be64 *rsp,netif_receive_skb (skb);return 0 ; - -nomem: -t4vf_pktgl_free (gl); - rxq->stats.rx_drops++; -return 0 ; }/**
Signature · 1 line
1.7.0.4
PATCH 4/6 cxgb4vf: flesh out PCI Device ID Table ...
In reply to Casey LeedomAdd a bunch of T4 Device IDs for the VF Driver.
--- drivers/net/cxgb4vf/cxgb4vf_main.c | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-)
drivers/net/cxgb4vf/cxgb4vf_main.c +8 -0
@@ -2829,6 +2829,14 @@ static struct pci_device_id cxgb4vf_pci_tbl[] = {CH_DEVICE (0x4800 ,0 ),/* T440-dbg */ CH_DEVICE (0x4801 ,0 ),/* T420-cr */ CH_DEVICE (0x4802 ,0 ),/* T422-cr */ +CH_DEVICE (0x4803 ,0 ),/* T440-cr */ +CH_DEVICE (0x4804 ,0 ),/* T420-bch */ +CH_DEVICE (0x4805 ,0 ),/* T440-bch */ +CH_DEVICE (0x4806 ,0 ),/* T460-ch */ +CH_DEVICE (0x4807 ,0 ),/* T420-so */ +CH_DEVICE (0x4808 ,0 ),/* T420-cx */ +CH_DEVICE (0x4809 ,0 ),/* T420-bt */ +CH_DEVICE (0x480a ,0 ),/* T404-bt */ { 0, } };
Signature · 1 line
1.7.0.4
PATCH 5/6 cxgb4vf: Fail open if link_start() fails.
In reply to Casey LeedomFail open if link_start() fails.
--- drivers/net/cxgb4vf/cxgb4vf_main.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)
drivers/net/cxgb4vf/cxgb4vf_main.c +3 -1
@@ -753,7 +753,9 @@ static int cxgb4vf_open(struct net_device *dev)if (err)return err;set_bit (pi->port_id, &adapter->open_device_map); -link_start (dev); + err =link_start (dev); +if (err) +return err;netif_tx_start_all_queues (dev);return 0 ; }
Signature · 1 line
1.7.0.4
PATCH 6/6 cxgb4vf: add call to Firmware to reset VF State.
In reply to Casey LeedomAdd call to Firmware to reset its VF State when we first attach to the VF.
--- drivers/net/cxgb4vf/cxgb4vf_main.c | 16 ++++++++++++++++ drivers/net/cxgb4vf/t4vf_common.h | 1 + drivers/net/cxgb4vf/t4vf_hw.c | 19 +++++++++++++++++++ 3 files changed, 36 insertions(+), 0 deletions(-)
drivers/net/cxgb4vf/cxgb4vf_main.c +16 -0
@@ -2065,6 +2065,22 @@ static int adap_init0(struct adapter *adapter) }/* +* Some environments do not properly handle PCIE FLRs -- e.g. in Linux +* 2.6.31 and later we can't call pci_reset_function() in order to +* issue an FLR because of a self- deadlock on the device semaphore. +* Meanwhile, the OS infrastructure doesn't issue FLRs in all the +* cases where they're needed -- for instance, some versions of KVM +* fail to reset "Assigned Devices" when the VM reboots. Therefore we +* use the firmware based reset in order to reset any per function +* state. +*/ + err =t4vf_fw_reset (adapter); +if (err <0 ) { +dev_err (adapter->pdev_dev,"FW reset failed: err=%d\n" , err); +return err; + } + +/* * Grab basic operational parameters. These will predominantly have * been set up by the Physical Function Driver or will be hard coded * into the adapter. We just have to live with them ... Note that
drivers/net/cxgb4vf/t4vf_common.h +1 -0
@@ -235,6 +235,7 @@ static inline int t4vf_wr_mbox_ns(struct adapter *adapter, const void *cmd,int __devinit t4vf_wait_dev_ready (struct adapter *);int __devinit t4vf_port_init (struct adapter *,int ); +int t4vf_fw_reset (struct adapter *);int t4vf_query_params (struct adapter *,unsigned int ,const u32 *,u32 *);int t4vf_set_params (struct adapter *,unsigned int ,const u32 *,const u32 *);
drivers/net/cxgb4vf/t4vf_hw.c +19 -0
@@ -326,6 +326,25 @@ int __devinit t4vf_port_init(struct adapter *adapter, int pidx) }/** +* t4vf_fw_reset - issue a reset to FW +* @adapter: the adapter +* +* Issues a reset command to FW. For a Physical Function this would +* result in the Firmware reseting all of its state. For a Virtual +* Function this just resets the state associated with the VF. +*/ +int t4vf_fw_reset (struct adapter *adapter) +{ +struct fw_reset_cmd cmd; + +memset (&cmd,0 ,sizeof (cmd)); + cmd.op_to_write =cpu_to_be32 (FW_CMD_OP (FW_RESET_CMD ) | +FW_CMD_WRITE ); + cmd.retval_len16 =cpu_to_be32 (FW_LEN16 (cmd)); +return t4vf_wr_mbox (adapter, &cmd,sizeof (cmd),NULL ); +} + +/** * t4vf_query_params - query FW or device parameters * @adapter: the adapter * @nparams: the number of parameters
Signature · 1 line
1.7.0.4
David Miller
maintainerFrom: Casey Leedom <[email protected]>
Date: Thu, 11 Nov 2010 11:06:47 -0800
Quoted 3 lines
The following patch set includes a number of bug fixes for the cxgb4vf network driver. As always, please toss these in the bin if they're not right.
All 6 patches applied to net-2.6, thanks.