Commit 0034b298 authored by Kumar Sanghvi's avatar Kumar Sanghvi Committed by David S. Miller

cxgb4: Don't assume LSO only uses SGL path in t4_eth_xmit()

Also, modify is_eth_imm() to return header length so it doesn't
have to be recomputed in calc_tx_flits().

Based on original work by Mike Werner <werner@chelsio.com>
Signed-off-by: default avatarKumar Sanghvi <kumaras@chelsio.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent c1f49e3e
...@@ -706,11 +706,17 @@ static inline unsigned int flits_to_desc(unsigned int n) ...@@ -706,11 +706,17 @@ static inline unsigned int flits_to_desc(unsigned int n)
* @skb: the packet * @skb: the packet
* *
* Returns whether an Ethernet packet is small enough to fit as * Returns whether an Ethernet packet is small enough to fit as
* immediate data. * immediate data. Return value corresponds to headroom required.
*/ */
static inline int is_eth_imm(const struct sk_buff *skb) static inline int is_eth_imm(const struct sk_buff *skb)
{ {
return skb->len <= MAX_IMM_TX_PKT_LEN - sizeof(struct cpl_tx_pkt); int hdrlen = skb_shinfo(skb)->gso_size ?
sizeof(struct cpl_tx_pkt_lso_core) : 0;
hdrlen += sizeof(struct cpl_tx_pkt);
if (skb->len <= MAX_IMM_TX_PKT_LEN - hdrlen)
return hdrlen;
return 0;
} }
/** /**
...@@ -723,9 +729,10 @@ static inline int is_eth_imm(const struct sk_buff *skb) ...@@ -723,9 +729,10 @@ static inline int is_eth_imm(const struct sk_buff *skb)
static inline unsigned int calc_tx_flits(const struct sk_buff *skb) static inline unsigned int calc_tx_flits(const struct sk_buff *skb)
{ {
unsigned int flits; unsigned int flits;
int hdrlen = is_eth_imm(skb);
if (is_eth_imm(skb)) if (hdrlen)
return DIV_ROUND_UP(skb->len + sizeof(struct cpl_tx_pkt), 8); return DIV_ROUND_UP(skb->len + hdrlen, sizeof(__be64));
flits = sgl_len(skb_shinfo(skb)->nr_frags + 1) + 4; flits = sgl_len(skb_shinfo(skb)->nr_frags + 1) + 4;
if (skb_shinfo(skb)->gso_size) if (skb_shinfo(skb)->gso_size)
...@@ -971,6 +978,7 @@ static inline void txq_advance(struct sge_txq *q, unsigned int n) ...@@ -971,6 +978,7 @@ static inline void txq_advance(struct sge_txq *q, unsigned int n)
*/ */
netdev_tx_t t4_eth_xmit(struct sk_buff *skb, struct net_device *dev) netdev_tx_t t4_eth_xmit(struct sk_buff *skb, struct net_device *dev)
{ {
int len;
u32 wr_mid; u32 wr_mid;
u64 cntrl, *end; u64 cntrl, *end;
int qidx, credits; int qidx, credits;
...@@ -982,6 +990,7 @@ netdev_tx_t t4_eth_xmit(struct sk_buff *skb, struct net_device *dev) ...@@ -982,6 +990,7 @@ netdev_tx_t t4_eth_xmit(struct sk_buff *skb, struct net_device *dev)
struct cpl_tx_pkt_core *cpl; struct cpl_tx_pkt_core *cpl;
const struct skb_shared_info *ssi; const struct skb_shared_info *ssi;
dma_addr_t addr[MAX_SKB_FRAGS + 1]; dma_addr_t addr[MAX_SKB_FRAGS + 1];
bool immediate = false;
/* /*
* The chip min packet length is 10 octets but play safe and reject * The chip min packet length is 10 octets but play safe and reject
...@@ -1011,7 +1020,10 @@ out_free: dev_kfree_skb(skb); ...@@ -1011,7 +1020,10 @@ out_free: dev_kfree_skb(skb);
return NETDEV_TX_BUSY; return NETDEV_TX_BUSY;
} }
if (!is_eth_imm(skb) && if (is_eth_imm(skb))
immediate = true;
if (!immediate &&
unlikely(map_skb(adap->pdev_dev, skb, addr) < 0)) { unlikely(map_skb(adap->pdev_dev, skb, addr) < 0)) {
q->mapping_err++; q->mapping_err++;
goto out_free; goto out_free;
...@@ -1028,6 +1040,8 @@ out_free: dev_kfree_skb(skb); ...@@ -1028,6 +1040,8 @@ out_free: dev_kfree_skb(skb);
wr->r3 = cpu_to_be64(0); wr->r3 = cpu_to_be64(0);
end = (u64 *)wr + flits; end = (u64 *)wr + flits;
len = immediate ? skb->len : 0;
len += sizeof(*cpl);
ssi = skb_shinfo(skb); ssi = skb_shinfo(skb);
if (ssi->gso_size) { if (ssi->gso_size) {
struct cpl_tx_pkt_lso *lso = (void *)wr; struct cpl_tx_pkt_lso *lso = (void *)wr;
...@@ -1035,8 +1049,9 @@ out_free: dev_kfree_skb(skb); ...@@ -1035,8 +1049,9 @@ out_free: dev_kfree_skb(skb);
int l3hdr_len = skb_network_header_len(skb); int l3hdr_len = skb_network_header_len(skb);
int eth_xtra_len = skb_network_offset(skb) - ETH_HLEN; int eth_xtra_len = skb_network_offset(skb) - ETH_HLEN;
len += sizeof(*lso);
wr->op_immdlen = htonl(FW_WR_OP(FW_ETH_TX_PKT_WR) | wr->op_immdlen = htonl(FW_WR_OP(FW_ETH_TX_PKT_WR) |
FW_WR_IMMDLEN(sizeof(*lso))); FW_WR_IMMDLEN(len));
lso->c.lso_ctrl = htonl(LSO_OPCODE(CPL_TX_PKT_LSO) | lso->c.lso_ctrl = htonl(LSO_OPCODE(CPL_TX_PKT_LSO) |
LSO_FIRST_SLICE | LSO_LAST_SLICE | LSO_FIRST_SLICE | LSO_LAST_SLICE |
LSO_IPV6(v6) | LSO_IPV6(v6) |
...@@ -1054,9 +1069,6 @@ out_free: dev_kfree_skb(skb); ...@@ -1054,9 +1069,6 @@ out_free: dev_kfree_skb(skb);
q->tso++; q->tso++;
q->tx_cso += ssi->gso_segs; q->tx_cso += ssi->gso_segs;
} else { } else {
int len;
len = is_eth_imm(skb) ? skb->len + sizeof(*cpl) : sizeof(*cpl);
wr->op_immdlen = htonl(FW_WR_OP(FW_ETH_TX_PKT_WR) | wr->op_immdlen = htonl(FW_WR_OP(FW_ETH_TX_PKT_WR) |
FW_WR_IMMDLEN(len)); FW_WR_IMMDLEN(len));
cpl = (void *)(wr + 1); cpl = (void *)(wr + 1);
...@@ -1078,7 +1090,7 @@ out_free: dev_kfree_skb(skb); ...@@ -1078,7 +1090,7 @@ out_free: dev_kfree_skb(skb);
cpl->len = htons(skb->len); cpl->len = htons(skb->len);
cpl->ctrl1 = cpu_to_be64(cntrl); cpl->ctrl1 = cpu_to_be64(cntrl);
if (is_eth_imm(skb)) { if (immediate) {
inline_tx_skb(skb, &q->q, cpl + 1); inline_tx_skb(skb, &q->q, cpl + 1);
dev_kfree_skb(skb); dev_kfree_skb(skb);
} else { } else {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment