Skip to content

Commit 091189a

Browse files
author
Jakub Kicinski
committed
Merge branch 'cxgb4-add-udp-segmentation-offload-support'
Rahul Lakkireddy says: ==================== This series of patches add UDP Segmentation Offload (USO) supported by Chelsio T5/T6 NICs. Patch 1 updates the current Scatter Gather List (SGL) DMA unmap logic for USO requests. Patch 2 adds USO support for NIC and MQPRIO QoS offload Tx path. Patch 3 adds missing stats for MQPRIO QoS offload Tx path. ==================== Signed-off-by: Jakub Kicinski <[email protected]>
2 parents a9f852e + 8311f0b commit 091189a

File tree

8 files changed

+218
-165
lines changed

8 files changed

+218
-165
lines changed

drivers/crypto/chelsio/chcr_ipsec.c

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -673,16 +673,16 @@ static inline void txq_advance(struct sge_txq *q, unsigned int n)
673673
int chcr_ipsec_xmit(struct sk_buff *skb, struct net_device *dev)
674674
{
675675
struct xfrm_state *x = xfrm_input_state(skb);
676+
unsigned int last_desc, ndesc, flits = 0;
676677
struct ipsec_sa_entry *sa_entry;
677678
u64 *pos, *end, *before, *sgl;
679+
struct tx_sw_desc *sgl_sdesc;
678680
int qidx, left, credits;
679-
unsigned int flits = 0, ndesc;
680-
struct adapter *adap;
681+
bool immediate = false;
681682
struct sge_eth_txq *q;
683+
struct adapter *adap;
682684
struct port_info *pi;
683-
dma_addr_t addr[MAX_SKB_FRAGS + 1];
684685
struct sec_path *sp;
685-
bool immediate = false;
686686

687687
if (!x->xso.offload_handle)
688688
return NETDEV_TX_BUSY;
@@ -715,8 +715,14 @@ out_free: dev_kfree_skb_any(skb);
715715
return NETDEV_TX_BUSY;
716716
}
717717

718+
last_desc = q->q.pidx + ndesc - 1;
719+
if (last_desc >= q->q.size)
720+
last_desc -= q->q.size;
721+
sgl_sdesc = &q->q.sdesc[last_desc];
722+
718723
if (!immediate &&
719-
unlikely(cxgb4_map_skb(adap->pdev_dev, skb, addr) < 0)) {
724+
unlikely(cxgb4_map_skb(adap->pdev_dev, skb, sgl_sdesc->addr) < 0)) {
725+
memset(sgl_sdesc->addr, 0, sizeof(sgl_sdesc->addr));
720726
q->mapping_err++;
721727
goto out_free;
722728
}
@@ -742,17 +748,10 @@ out_free: dev_kfree_skb_any(skb);
742748
cxgb4_inline_tx_skb(skb, &q->q, sgl);
743749
dev_consume_skb_any(skb);
744750
} else {
745-
int last_desc;
746-
747751
cxgb4_write_sgl(skb, &q->q, (void *)sgl, end,
748-
0, addr);
752+
0, sgl_sdesc->addr);
749753
skb_orphan(skb);
750-
751-
last_desc = q->q.pidx + ndesc - 1;
752-
if (last_desc >= q->q.size)
753-
last_desc -= q->q.size;
754-
q->q.sdesc[last_desc].skb = skb;
755-
q->q.sdesc[last_desc].sgl = (struct ulptx_sgl *)sgl;
754+
sgl_sdesc->skb = skb;
756755
}
757756
txq_advance(&q->q, ndesc);
758757

drivers/net/ethernet/chelsio/cxgb4/cxgb4.h

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,12 @@ struct tx_desc {
735735
__be64 flit[8];
736736
};
737737

738-
struct tx_sw_desc;
738+
struct ulptx_sgl;
739+
740+
struct tx_sw_desc {
741+
struct sk_buff *skb; /* SKB to free after getting completion */
742+
dma_addr_t addr[MAX_SKB_FRAGS + 1]; /* DMA mapped addresses */
743+
};
739744

740745
struct sge_txq {
741746
unsigned int in_use; /* # of in-use Tx descriptors */
@@ -767,6 +772,7 @@ struct sge_eth_txq { /* state for an SGE Ethernet Tx queue */
767772
u8 dbqt; /* SGE Doorbell Queue Timer in use */
768773
unsigned int dbqtimerix; /* SGE Doorbell Queue Timer Index */
769774
unsigned long tso; /* # of TSO requests */
775+
unsigned long uso; /* # of USO requests */
770776
unsigned long tx_cso; /* # of Tx checksum offloads */
771777
unsigned long vlan_ins; /* # of Tx VLAN insertions */
772778
unsigned long mapping_err; /* # of I/O MMU packet mapping errors */
@@ -814,15 +820,10 @@ enum sge_eosw_state {
814820
CXGB4_EO_STATE_FLOWC_CLOSE_REPLY, /* Waiting for FLOWC close reply */
815821
};
816822

817-
struct sge_eosw_desc {
818-
struct sk_buff *skb; /* SKB to free after getting completion */
819-
dma_addr_t addr[MAX_SKB_FRAGS + 1]; /* DMA mapped addresses */
820-
};
821-
822823
struct sge_eosw_txq {
823824
spinlock_t lock; /* Per queue lock to synchronize completions */
824825
enum sge_eosw_state state; /* Current ETHOFLD State */
825-
struct sge_eosw_desc *desc; /* Descriptor ring to hold packets */
826+
struct tx_sw_desc *desc; /* Descriptor ring to hold packets */
826827
u32 ndesc; /* Number of descriptors */
827828
u32 pidx; /* Current Producer Index */
828829
u32 last_pidx; /* Last successfully transmitted Producer Index */
@@ -849,6 +850,7 @@ struct sge_eohw_txq {
849850
struct sge_txq q; /* HW Txq */
850851
struct adapter *adap; /* Backpointer to adapter */
851852
unsigned long tso; /* # of TSO requests */
853+
unsigned long uso; /* # of USO requests */
852854
unsigned long tx_cso; /* # of Tx checksum offloads */
853855
unsigned long vlan_ins; /* # of Tx VLAN insertions */
854856
unsigned long mapping_err; /* # of I/O MMU packet mapping errors */
@@ -1151,11 +1153,6 @@ enum {
11511153
SCHED_CLASS_RATEMODE_ABS = 1, /* Kb/s */
11521154
};
11531155

1154-
struct tx_sw_desc { /* SW state per Tx descriptor */
1155-
struct sk_buff *skb;
1156-
struct ulptx_sgl *sgl;
1157-
};
1158-
11591156
/* Support for "sched_queue" command to allow one or more NIC TX Queues
11601157
* to be bound to a TX Scheduling Class.
11611158
*/

drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2748,6 +2748,7 @@ do { \
27482748
RL("RxDrops:", stats.rx_drops);
27492749
RL("RxBadPkts:", stats.bad_rx_pkts);
27502750
TL("TSO:", tso);
2751+
TL("USO:", uso);
27512752
TL("TxCSO:", tx_cso);
27522753
TL("VLANins:", vlan_ins);
27532754
TL("TxQFull:", q.stops);
@@ -2796,6 +2797,7 @@ do { \
27962797
RL("RxAN", stats.an);
27972798
RL("RxNoMem", stats.nomem);
27982799
TL("TSO:", tso);
2800+
TL("USO:", uso);
27992801
TL("TxCSO:", tx_cso);
28002802
TL("VLANins:", vlan_ins);
28012803
TL("TxQFull:", q.stops);

drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ static const char stats_strings[][ETH_GSTRING_LEN] = {
9191
"rx_bg3_frames_trunc ",
9292

9393
"tso ",
94+
"uso ",
9495
"tx_csum_offload ",
9596
"rx_csum_good ",
9697
"vlan_extractions ",
@@ -220,6 +221,7 @@ static void get_strings(struct net_device *dev, u32 stringset, u8 *data)
220221
*/
221222
struct queue_port_stats {
222223
u64 tso;
224+
u64 uso;
223225
u64 tx_csum;
224226
u64 rx_csum;
225227
u64 vlan_ex;
@@ -240,20 +242,32 @@ static void collect_sge_port_stats(const struct adapter *adap,
240242
const struct port_info *p,
241243
struct queue_port_stats *s)
242244
{
243-
int i;
244245
const struct sge_eth_txq *tx = &adap->sge.ethtxq[p->first_qset];
245246
const struct sge_eth_rxq *rx = &adap->sge.ethrxq[p->first_qset];
247+
struct sge_eohw_txq *eohw_tx;
248+
unsigned int i;
246249

247250
memset(s, 0, sizeof(*s));
248251
for (i = 0; i < p->nqsets; i++, rx++, tx++) {
249252
s->tso += tx->tso;
253+
s->uso += tx->uso;
250254
s->tx_csum += tx->tx_cso;
251255
s->rx_csum += rx->stats.rx_cso;
252256
s->vlan_ex += rx->stats.vlan_ex;
253257
s->vlan_ins += tx->vlan_ins;
254258
s->gro_pkts += rx->stats.lro_pkts;
255259
s->gro_merged += rx->stats.lro_merged;
256260
}
261+
262+
if (adap->sge.eohw_txq) {
263+
eohw_tx = &adap->sge.eohw_txq[p->first_qset];
264+
for (i = 0; i < p->nqsets; i++, eohw_tx++) {
265+
s->tso += eohw_tx->tso;
266+
s->uso += eohw_tx->uso;
267+
s->tx_csum += eohw_tx->tx_cso;
268+
s->vlan_ins += eohw_tx->vlan_ins;
269+
}
270+
}
257271
}
258272

259273
static void collect_adapter_stats(struct adapter *adap, struct adapter_stats *s)

drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1136,11 +1136,17 @@ static u16 cxgb_select_queue(struct net_device *dev, struct sk_buff *skb,
11361136

11371137
if (dev->num_tc) {
11381138
struct port_info *pi = netdev2pinfo(dev);
1139+
u8 ver, proto;
1140+
1141+
ver = ip_hdr(skb)->version;
1142+
proto = (ver == 6) ? ipv6_hdr(skb)->nexthdr :
1143+
ip_hdr(skb)->protocol;
11391144

11401145
/* Send unsupported traffic pattern to normal NIC queues. */
11411146
txq = netdev_pick_tx(dev, skb, sb_dev);
11421147
if (xfrm_offload(skb) || is_ptp_enabled(skb, dev) ||
1143-
ip_hdr(skb)->protocol != IPPROTO_TCP)
1148+
skb->encapsulation ||
1149+
(proto != IPPROTO_TCP && proto != IPPROTO_UDP))
11441150
txq = txq % pi->nqsets;
11451151

11461152
return txq;
@@ -5838,7 +5844,8 @@ static void free_some_resources(struct adapter *adapter)
58385844
t4_fw_bye(adapter, adapter->pf);
58395845
}
58405846

5841-
#define TSO_FLAGS (NETIF_F_TSO | NETIF_F_TSO6 | NETIF_F_TSO_ECN)
5847+
#define TSO_FLAGS (NETIF_F_TSO | NETIF_F_TSO6 | NETIF_F_TSO_ECN | \
5848+
NETIF_F_GSO_UDP_L4)
58425849
#define VLAN_FEAT (NETIF_F_SG | NETIF_F_IP_CSUM | TSO_FLAGS | \
58435850
NETIF_F_GRO | NETIF_F_IPV6_CSUM | NETIF_F_HIGHDMA)
58445851
#define SEGMENT_SIZE 128

drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_mqprio.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ static int cxgb4_init_eosw_txq(struct net_device *dev,
7070
u32 eotid, u32 hwqid)
7171
{
7272
struct adapter *adap = netdev2adap(dev);
73-
struct sge_eosw_desc *ring;
73+
struct tx_sw_desc *ring;
7474

7575
memset(eosw_txq, 0, sizeof(*eosw_txq));
7676

0 commit comments

Comments
 (0)