Skip to content

Commit f5f9649

Browse files
committed
Merge branch 'thunderx-pass2'
Sunil Goutham says: ==================== net: thunderx: Support for pass-2 hw features This patch set adds support for new features added in pass-2 revision of hardware like TSO and count based interrupt coalescing. Changes from v1: - Addressed comments received regarding boolean bit field changes by excluding them from this patch. Will submit a seperate patch along with cleanup of unsed field. - Got rid of new macro 'VNIC_NAPI_WEIGHT' introduced in count threshold interrupt patch. ==================== Reviewed-by: Pavel Fedin <p.fedin@samsung.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents 2ad7b75 + b9687b4 commit f5f9649

File tree

6 files changed

+55
-31
lines changed

6 files changed

+55
-31
lines changed

drivers/net/ethernet/cavium/thunder/nic.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@ struct nicvf {
265265
u8 tns_mode:1;
266266
u8 sqs_mode:1;
267267
u8 loopback_supported:1;
268+
bool hw_tso;
268269
u16 mtu;
269270
struct queue_set *qs;
270271
#define MAX_SQS_PER_VF_SINGLE_NODE 5
@@ -489,6 +490,11 @@ static inline int nic_get_node_id(struct pci_dev *pdev)
489490
return ((addr >> NIC_NODE_ID_SHIFT) & NIC_NODE_ID_MASK);
490491
}
491492

493+
static inline bool pass1_silicon(struct pci_dev *pdev)
494+
{
495+
return pdev->revision < 8;
496+
}
497+
492498
int nicvf_set_real_num_queues(struct net_device *netdev,
493499
int tx_queues, int rx_queues);
494500
int nicvf_open(struct net_device *netdev);

drivers/net/ethernet/cavium/thunder/nic_main.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,6 @@ struct nicpf {
5555
bool irq_allocated[NIC_PF_MSIX_VECTORS];
5656
};
5757

58-
static inline bool pass1_silicon(struct nicpf *nic)
59-
{
60-
return nic->pdev->revision < 8;
61-
}
62-
6358
/* Supported devices */
6459
static const struct pci_device_id nic_id_table[] = {
6560
{ PCI_DEVICE(PCI_VENDOR_ID_CAVIUM, PCI_DEVICE_ID_THUNDER_NIC_PF) },
@@ -123,7 +118,7 @@ static void nic_send_msg_to_vf(struct nicpf *nic, int vf, union nic_mbx *mbx)
123118
* when PF writes to MBOX(1), in next revisions when
124119
* PF writes to MBOX(0)
125120
*/
126-
if (pass1_silicon(nic)) {
121+
if (pass1_silicon(nic->pdev)) {
127122
/* see the comment for nic_reg_write()/nic_reg_read()
128123
* functions above
129124
*/
@@ -400,7 +395,7 @@ static void nic_config_cpi(struct nicpf *nic, struct cpi_cfg_msg *cfg)
400395
padd = cpi % 8; /* 3 bits CS out of 6bits DSCP */
401396

402397
/* Leave RSS_SIZE as '0' to disable RSS */
403-
if (pass1_silicon(nic)) {
398+
if (pass1_silicon(nic->pdev)) {
404399
nic_reg_write(nic, NIC_PF_CPI_0_2047_CFG | (cpi << 3),
405400
(vnic << 24) | (padd << 16) |
406401
(rssi_base + rssi));
@@ -470,7 +465,7 @@ static void nic_config_rss(struct nicpf *nic, struct rss_cfg_msg *cfg)
470465
}
471466

472467
cpi_base = nic->cpi_base[cfg->vf_id];
473-
if (pass1_silicon(nic))
468+
if (pass1_silicon(nic->pdev))
474469
idx_addr = NIC_PF_CPI_0_2047_CFG;
475470
else
476471
idx_addr = NIC_PF_MPI_0_2047_CFG;

drivers/net/ethernet/cavium/thunder/nicvf_main.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -525,14 +525,22 @@ static void nicvf_snd_pkt_handler(struct net_device *netdev,
525525
__func__, cqe_tx->sq_qs, cqe_tx->sq_idx,
526526
cqe_tx->sqe_ptr, hdr->subdesc_cnt);
527527

528-
nicvf_put_sq_desc(sq, hdr->subdesc_cnt + 1);
529528
nicvf_check_cqe_tx_errs(nic, cq, cqe_tx);
530529
skb = (struct sk_buff *)sq->skbuff[cqe_tx->sqe_ptr];
531-
/* For TSO offloaded packets only one head SKB needs to be freed */
530+
/* For TSO offloaded packets only one SQE will have a valid SKB */
532531
if (skb) {
532+
nicvf_put_sq_desc(sq, hdr->subdesc_cnt + 1);
533533
prefetch(skb);
534534
dev_consume_skb_any(skb);
535535
sq->skbuff[cqe_tx->sqe_ptr] = (u64)NULL;
536+
} else {
537+
/* In case of HW TSO, HW sends a CQE for each segment of a TSO
538+
* packet instead of a single CQE for the whole TSO packet
539+
* transmitted. Each of this CQE points to the same SQE, so
540+
* avoid freeing same SQE multiple times.
541+
*/
542+
if (!nic->hw_tso)
543+
nicvf_put_sq_desc(sq, hdr->subdesc_cnt + 1);
536544
}
537545
}
538546

@@ -1549,6 +1557,9 @@ static int nicvf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
15491557

15501558
netdev->vlan_features = NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_TSO;
15511559

1560+
if (!pass1_silicon(nic->pdev))
1561+
nic->hw_tso = true;
1562+
15521563
netdev->netdev_ops = &nicvf_netdev_ops;
15531564
netdev->watchdog_timeo = NICVF_TX_TIMEOUT;
15541565

drivers/net/ethernet/cavium/thunder/nicvf_queues.c

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ static int nicvf_init_cmp_queue(struct nicvf *nic,
299299
return err;
300300

301301
cq->desc = cq->dmem.base;
302-
cq->thresh = CMP_QUEUE_CQE_THRESH;
302+
cq->thresh = pass1_silicon(nic->pdev) ? 0 : CMP_QUEUE_CQE_THRESH;
303303
nic->cq_coalesce_usecs = (CMP_QUEUE_TIMER_THRESH * 0.05) - 1;
304304

305305
return 0;
@@ -925,7 +925,7 @@ static int nicvf_sq_subdesc_required(struct nicvf *nic, struct sk_buff *skb)
925925
{
926926
int subdesc_cnt = MIN_SQ_DESC_PER_PKT_XMIT;
927927

928-
if (skb_shinfo(skb)->gso_size) {
928+
if (skb_shinfo(skb)->gso_size && !nic->hw_tso) {
929929
subdesc_cnt = nicvf_tso_count_subdescs(skb);
930930
return subdesc_cnt;
931931
}
@@ -940,7 +940,7 @@ static int nicvf_sq_subdesc_required(struct nicvf *nic, struct sk_buff *skb)
940940
* First subdescriptor for every send descriptor.
941941
*/
942942
static inline void
943-
nicvf_sq_add_hdr_subdesc(struct snd_queue *sq, int qentry,
943+
nicvf_sq_add_hdr_subdesc(struct nicvf *nic, struct snd_queue *sq, int qentry,
944944
int subdesc_cnt, struct sk_buff *skb, int len)
945945
{
946946
int proto;
@@ -976,6 +976,15 @@ nicvf_sq_add_hdr_subdesc(struct snd_queue *sq, int qentry,
976976
break;
977977
}
978978
}
979+
980+
if (nic->hw_tso && skb_shinfo(skb)->gso_size) {
981+
hdr->tso = 1;
982+
hdr->tso_start = skb_transport_offset(skb) + tcp_hdrlen(skb);
983+
hdr->tso_max_paysize = skb_shinfo(skb)->gso_size;
984+
/* For non-tunneled pkts, point this to L2 ethertype */
985+
hdr->inner_l3_offset = skb_network_offset(skb) - 2;
986+
nic->drv_stats.tx_tso++;
987+
}
979988
}
980989

981990
/* SQ GATHER subdescriptor
@@ -1045,7 +1054,7 @@ static int nicvf_sq_append_tso(struct nicvf *nic, struct snd_queue *sq,
10451054
data_left -= size;
10461055
tso_build_data(skb, &tso, size);
10471056
}
1048-
nicvf_sq_add_hdr_subdesc(sq, hdr_qentry,
1057+
nicvf_sq_add_hdr_subdesc(nic, sq, hdr_qentry,
10491058
seg_subdescs - 1, skb, seg_len);
10501059
sq->skbuff[hdr_qentry] = (u64)NULL;
10511060
qentry = nicvf_get_nxt_sqentry(sq, qentry);
@@ -1098,11 +1107,12 @@ int nicvf_sq_append_skb(struct nicvf *nic, struct sk_buff *skb)
10981107
qentry = nicvf_get_sq_desc(sq, subdesc_cnt);
10991108

11001109
/* Check if its a TSO packet */
1101-
if (skb_shinfo(skb)->gso_size)
1110+
if (skb_shinfo(skb)->gso_size && !nic->hw_tso)
11021111
return nicvf_sq_append_tso(nic, sq, sq_num, qentry, skb);
11031112

11041113
/* Add SQ header subdesc */
1105-
nicvf_sq_add_hdr_subdesc(sq, qentry, subdesc_cnt - 1, skb, skb->len);
1114+
nicvf_sq_add_hdr_subdesc(nic, sq, qentry, subdesc_cnt - 1,
1115+
skb, skb->len);
11061116

11071117
/* Add SQ gather subdescs */
11081118
qentry = nicvf_get_nxt_sqentry(sq, qentry);

drivers/net/ethernet/cavium/thunder/nicvf_queues.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
*/
7676
#define CMP_QSIZE CMP_QUEUE_SIZE2
7777
#define CMP_QUEUE_LEN (1ULL << (CMP_QSIZE + 10))
78-
#define CMP_QUEUE_CQE_THRESH 0
78+
#define CMP_QUEUE_CQE_THRESH (NAPI_POLL_WEIGHT / 2)
7979
#define CMP_QUEUE_TIMER_THRESH 80 /* ~2usec */
8080

8181
#define RBDR_SIZE RBDR_SIZE0

drivers/net/ethernet/cavium/thunder/q_struct.h

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -545,25 +545,28 @@ struct sq_hdr_subdesc {
545545
u64 subdesc_cnt:8;
546546
u64 csum_l4:2;
547547
u64 csum_l3:1;
548-
u64 rsvd0:5;
548+
u64 csum_inner_l4:2;
549+
u64 csum_inner_l3:1;
550+
u64 rsvd0:2;
549551
u64 l4_offset:8;
550552
u64 l3_offset:8;
551553
u64 rsvd1:4;
552554
u64 tot_len:20; /* W0 */
553555

554-
u64 tso_sdc_cont:8;
555-
u64 tso_sdc_first:8;
556-
u64 tso_l4_offset:8;
557-
u64 tso_flags_last:12;
558-
u64 tso_flags_first:12;
559-
u64 rsvd2:2;
556+
u64 rsvd2:24;
557+
u64 inner_l4_offset:8;
558+
u64 inner_l3_offset:8;
559+
u64 tso_start:8;
560+
u64 rsvd3:2;
560561
u64 tso_max_paysize:14; /* W1 */
561562
#elif defined(__LITTLE_ENDIAN_BITFIELD)
562563
u64 tot_len:20;
563564
u64 rsvd1:4;
564565
u64 l3_offset:8;
565566
u64 l4_offset:8;
566-
u64 rsvd0:5;
567+
u64 rsvd0:2;
568+
u64 csum_inner_l3:1;
569+
u64 csum_inner_l4:2;
567570
u64 csum_l3:1;
568571
u64 csum_l4:2;
569572
u64 subdesc_cnt:8;
@@ -574,12 +577,11 @@ struct sq_hdr_subdesc {
574577
u64 subdesc_type:4; /* W0 */
575578

576579
u64 tso_max_paysize:14;
577-
u64 rsvd2:2;
578-
u64 tso_flags_first:12;
579-
u64 tso_flags_last:12;
580-
u64 tso_l4_offset:8;
581-
u64 tso_sdc_first:8;
582-
u64 tso_sdc_cont:8; /* W1 */
580+
u64 rsvd3:2;
581+
u64 tso_start:8;
582+
u64 inner_l3_offset:8;
583+
u64 inner_l4_offset:8;
584+
u64 rsvd2:24; /* W1 */
583585
#endif
584586
};
585587

0 commit comments

Comments
 (0)