net: thunderx: Miscellaneous fixes
Subsystems (3)
v2 cover net: thunderx: Miscellaneous fixes
From: Sunil Goutham <[email protected]>
This patch set fixes multiple issues such as IOMMU translation faults when kernel is booted with IOMMU enabled on host, incorrect MAC ID reading from ACPI tables and IPv6 UDP packet drop due to failure of checksum validation.
Changes from v1:
- As suggested by David Miller, got rid of conditional calling of DMA map/unmap APIs. Also updated commit message in 'IOMMU translation faults' patch.
Sunil Goutham (3):
net: thunderx: Fix IOMMU translation faults
net: thunderx: Fix LMAC mode debug prints for QSGMII mode
net: thunderx: Fix invalid mac addresses for node1 interfaces
Thanneeru Srinivasulu (1):
net: thunderx: Allow IPv6 frames with zero UDP checksum
drivers/net/ethernet/cavium/thunder/nic.h | 1 + drivers/net/ethernet/cavium/thunder/nicvf_main.c | 12 +- drivers/net/ethernet/cavium/thunder/nicvf_queues.c | 184 ++++++++++++++++----- drivers/net/ethernet/cavium/thunder/nicvf_queues.h | 4 +- drivers/net/ethernet/cavium/thunder/thunder_bgx.c | 64 ++++--- drivers/net/ethernet/cavium/thunder/thunder_bgx.h | 1 - 6 files changed, 205 insertions(+), 61 deletions(-)
Signature · 1 line
2.7.4
PATCH v2 1/4 net: thunderx: Fix IOMMU translation faults
From: Sunil Goutham <[email protected]>
ACPI support has been added to ARM IOMMU driver in 4.10 kernel and that has resulted in VNIC interfaces throwing translation faults when kernel is booted with ACPI as driver was not using DMA API. This patch fixes the issue by using DMA API which inturn will create translation tables when IOMMU is enabled.
Also VNIC doesn't have a seperate receive buffer ring per receive queue, so there is no 1:1 descriptor index matching between CQE_RX and the index in buffer ring from where a buffer has been used for DMA'ing. Unlike other NICs, here it's not possible to maintain dma address to virt address mappings within the driver. This leaves us no other choice but to use IOMMU's IOVA address conversion API to get buffer's virtual address which can be given to network stack for processing.
--- drivers/net/ethernet/cavium/thunder/nic.h | 1 + drivers/net/ethernet/cavium/thunder/nicvf_main.c | 12 +- drivers/net/ethernet/cavium/thunder/nicvf_queues.c | 178 ++++++++++++++++----- drivers/net/ethernet/cavium/thunder/nicvf_queues.h | 4 +- 4 files changed, 156 insertions(+), 39 deletions(-)
drivers/net/ethernet/cavium/thunder/nic.h +1 -0
@@ -269,6 +269,7 @@ struct nicvf {#define MAX_QUEUES_PER_QSET 8struct queue_set *qs;struct nicvf_cq_poll *napi[8 ]; +void *iommu_domain;u8 vf_id;u8 sqs_id;bool sqs_mode;
drivers/net/ethernet/cavium/thunder/nicvf_main.c +11 -1
@@ -16,6 +16,7 @@#include <linux/log2.h> #include <linux/prefetch.h> #include <linux/irq.h> +#include <linux/iommu.h> #include "nic_reg.h" #include "nic.h"
@@ -525,7 +526,12 @@ static void nicvf_snd_pkt_handler(struct net_device *netdev,/* Get actual TSO descriptors and free them */ tso_sqe = (struct sq_hdr_subdesc *)GET_SQ_DESC (sq, hdr->rsvd2); +nicvf_unmap_sndq_buffers (nic, sq, hdr->rsvd2, + tso_sqe->subdesc_cnt);nicvf_put_sq_desc (sq, tso_sqe->subdesc_cnt +1 ); + }else { +nicvf_unmap_sndq_buffers (nic, sq, cqe_tx->sqe_ptr, + hdr->subdesc_cnt); }nicvf_put_sq_desc (sq, hdr->subdesc_cnt +1 );prefetch (skb);
@@ -576,6 +582,7 @@ static void nicvf_rcv_pkt_handler(struct net_device *netdev, {struct sk_buff *skb;struct nicvf *nic =netdev_priv (netdev); +struct nicvf *snic = nic;int err =0 ;int rq_idx;
@@ -592,7 +599,7 @@ static void nicvf_rcv_pkt_handler(struct net_device *netdev,if (err && !cqe_rx->rb_cnt)return ; - skb =nicvf_get_rcv_skb (nic, cqe_rx); + skb =nicvf_get_rcv_skb (snic, cqe_rx);if (!skb) {netdev_dbg (nic->netdev,"Packet not received\n" );return ;
@@ -1643,6 +1650,9 @@ static int nicvf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)if (!pass1_silicon (nic->pdev)) nic->hw_tso = true; +/* Get iommu domain for iova to physical addr conversion */ + nic->iommu_domain =iommu_get_domain_for_dev (dev); +pci_read_config_word (nic->pdev,PCI_SUBSYSTEM_ID , &sdevid);if (sdevid ==0xA134 ) nic->t88 = true;
drivers/net/ethernet/cavium/thunder/nicvf_queues.c +141 -37
317 lines not on this page · raw message
drivers/net/ethernet/cavium/thunder/nicvf_queues.h +3 -1
@@ -87,7 +87,7 @@#define RCV_BUF_COUNT (1ULL << (RBDR_SIZE + 13))#define MAX_RCV_BUF_COUNT (1ULL << (RBDR_SIZE6 + 13))#define RBDR_THRESH (RCV_BUF_COUNT / 2) -#define DMA_BUFFER_LEN 2048/* In multiples of 128bytes */ +#define DMA_BUFFER_LEN 1536/* In multiples of 128bytes */ #define RCV_FRAG_LEN (SKB_DATA_ALIGN(DMA_BUFFER_LEN + NET_SKB_PAD) + \ SKB_DATA_ALIGN(sizeof(struct skb_shared_info)))
@@ -301,6 +301,8 @@ struct queue_set {#define CQ_ERR_MASK (CQ_WR_FULL | CQ_WR_DISABLE | CQ_WR_FAULT) +void nicvf_unmap_sndq_buffers (struct nicvf *nic,struct snd_queue *sq, +int hdr_sqe,u8 subdesc_cnt);void nicvf_config_vlan_stripping (struct nicvf *nic,netdev_features_t features);int nicvf_set_qset_resources (struct nicvf *nic);
Signature · 1 line
2.7.4
PATCH v2 2/4 net: thunderx: Fix LMAC mode debug prints for QSGMII mode
In reply to [email protected]From: Sunil Goutham <[email protected]>
When BGX/LMACs are in QSGMII mode, for some LMACs, mode info is not being printed. This patch will fix that. With changes already done to not do any sort of serdes 2 lane mapping config calculation in kernel driver, we can get rid of this logic.
--- drivers/net/ethernet/cavium/thunder/thunder_bgx.c | 6 ------ 1 file changed, 6 deletions(-)
drivers/net/ethernet/cavium/thunder/thunder_bgx.c +0 -6
@@ -1011,12 +1011,6 @@ static void bgx_print_qlm_mode(struct bgx *bgx, u8 lmacid)dev_info (dev,"%s: 40G_KR4\n" , (char *)str);break ;case BGX_MODE_QSGMII : -if ((lmacid ==0 ) && - (bgx_get_lane2sds_cfg (bgx, lmac) != lmacid)) -return ; -if ((lmacid ==2 ) && - (bgx_get_lane2sds_cfg (bgx, lmac) == lmacid)) -return ;dev_info (dev,"%s: QSGMII\n" , (char *)str);break ;case BGX_MODE_RGMII :
Signature · 1 line
2.7.4
PATCH v2 3/4 net: thunderx: Fix invalid mac addresses for node1 interfaces
In reply to [email protected]From: Sunil Goutham <[email protected]>
When booted with ACPI, random mac addresses are being assigned to node1 interfaces due to mismatch of bgx_id in BGX driver and ACPI tables.
This patch fixes this issue by setting maximum BGX devices per node based on platform/soc instead of a macro. This change will set the bgx_id appropriately.
--- drivers/net/ethernet/cavium/thunder/thunder_bgx.c | 58 ++++++++++++++++++----- drivers/net/ethernet/cavium/thunder/thunder_bgx.h | 1 - 2 files changed, 45 insertions(+), 14 deletions(-)
drivers/net/ethernet/cavium/thunder/thunder_bgx.c +45 -13
@@ -123,14 +123,44 @@ static int bgx_poll_reg(struct bgx *bgx, u8 lmac, u64 reg, u64 mask, bool zero)return 1 ; } +static int max_bgx_per_node; +static void set_max_bgx_per_node (struct pci_dev *pdev) +{ +u16 sdevid; + +if (max_bgx_per_node) +return ; + +pci_read_config_word (pdev,PCI_SUBSYSTEM_ID , &sdevid); +switch (sdevid) { +case PCI_SUBSYS_DEVID_81XX_BGX : + max_bgx_per_node =MAX_BGX_PER_CN81XX ; +break ; +case PCI_SUBSYS_DEVID_83XX_BGX : + max_bgx_per_node =MAX_BGX_PER_CN83XX ; +break ; +case PCI_SUBSYS_DEVID_88XX_BGX : +default : + max_bgx_per_node =MAX_BGX_PER_CN88XX ; +break ; + } +} + +static struct bgx *get_bgx (int node,int bgx_idx) +{ +int idx = (node * max_bgx_per_node) + bgx_idx; + +return bgx_vnic[idx]; +} +/* Return number of BGX present in HW */ unsigned bgx_get_map (int node) {int i;unsigned map =0 ; -for (i =0 ; i <MAX_BGX_PER_NODE ; i++) { -if (bgx_vnic[(node *MAX_BGX_PER_NODE ) + i]) +for (i =0 ; i < max_bgx_per_node; i++) { +if (bgx_vnic[(node * max_bgx_per_node) + i]) map |= (1 << i); }
@@ -143,7 +173,7 @@ int bgx_get_lmac_count(int node, int bgx_idx) {struct bgx *bgx; - bgx = bgx_vnic[(node *MAX_BGX_PER_NODE ) + bgx_idx]; + bgx =get_bgx (node, bgx_idx);if (bgx)return bgx->lmac_count;
@@ -158,7 +188,7 @@ void bgx_get_lmac_link_state(int node, int bgx_idx, int lmacid, void *status)struct bgx *bgx;struct lmac *lmac; - bgx = bgx_vnic[(node *MAX_BGX_PER_NODE ) + bgx_idx]; + bgx =get_bgx (node, bgx_idx);if (!bgx)return ;
@@ -172,7 +202,7 @@ EXPORT_SYMBOL(bgx_get_lmac_link_state);const u8 *bgx_get_lmac_mac (int node,int bgx_idx,int lmacid) { -struct bgx *bgx = bgx_vnic[(node *MAX_BGX_PER_NODE ) + bgx_idx]; +struct bgx *bgx =get_bgx (node, bgx_idx);if (bgx)return bgx->lmac[lmacid].mac;
@@ -183,7 +213,7 @@ EXPORT_SYMBOL(bgx_get_lmac_mac);void bgx_set_lmac_mac (int node,int bgx_idx,int lmacid,const u8 *mac) { -struct bgx *bgx = bgx_vnic[(node *MAX_BGX_PER_NODE ) + bgx_idx]; +struct bgx *bgx =get_bgx (node, bgx_idx);if (!bgx)return ;
@@ -194,7 +224,7 @@ EXPORT_SYMBOL(bgx_set_lmac_mac);void bgx_lmac_rx_tx_enable (int node,int bgx_idx,int lmacid,bool enable) { -struct bgx *bgx = bgx_vnic[(node *MAX_BGX_PER_NODE ) + bgx_idx]; +struct bgx *bgx =get_bgx (node, bgx_idx);struct lmac *lmac;u64 cfg;
@@ -217,7 +247,7 @@ EXPORT_SYMBOL(bgx_lmac_rx_tx_enable);void bgx_lmac_get_pfc (int node,int bgx_idx,int lmacid,void *pause) {struct pfc *pfc = (struct pfc *)pause; -struct bgx *bgx = bgx_vnic[(node *MAX_BGX_PER_CN88XX ) + bgx_idx]; +struct bgx *bgx =get_bgx (node, bgx_idx);struct lmac *lmac;u64 cfg;
@@ -237,7 +267,7 @@ EXPORT_SYMBOL(bgx_lmac_get_pfc);void bgx_lmac_set_pfc (int node,int bgx_idx,int lmacid,void *pause) {struct pfc *pfc = (struct pfc *)pause; -struct bgx *bgx = bgx_vnic[(node *MAX_BGX_PER_CN88XX ) + bgx_idx]; +struct bgx *bgx =get_bgx (node, bgx_idx);struct lmac *lmac;u64 cfg;
@@ -369,7 +399,7 @@ u64 bgx_get_rx_stats(int node, int bgx_idx, int lmac, int idx) {struct bgx *bgx; - bgx = bgx_vnic[(node *MAX_BGX_PER_NODE ) + bgx_idx]; + bgx =get_bgx (node, bgx_idx);if (!bgx)return 0 ;
@@ -383,7 +413,7 @@ u64 bgx_get_tx_stats(int node, int bgx_idx, int lmac, int idx) {struct bgx *bgx; - bgx = bgx_vnic[(node *MAX_BGX_PER_NODE ) + bgx_idx]; + bgx =get_bgx (node, bgx_idx);if (!bgx)return 0 ;
@@ -411,7 +441,7 @@ void bgx_lmac_internal_loopback(int node, int bgx_idx,struct lmac *lmac;u64 cfg; - bgx = bgx_vnic[(node *MAX_BGX_PER_NODE ) + bgx_idx]; + bgx =get_bgx (node, bgx_idx);if (!bgx)return ;
@@ -1328,11 +1358,13 @@ static int bgx_probe(struct pci_dev *pdev, const struct pci_device_id *ent) goto err_release_regions; } +set_max_bgx_per_node (pdev); +pci_read_config_word (pdev,PCI_DEVICE_ID , &sdevid);if (sdevid !=PCI_DEVICE_ID_THUNDER_RGX ) { bgx->bgx_id = (pci_resource_start (pdev,PCI_CFG_REG_BAR_NUM ) >>24 ) &BGX_ID_MASK ; - bgx->bgx_id +=nic_get_node_id (pdev) *MAX_BGX_PER_NODE ; + bgx->bgx_id +=nic_get_node_id (pdev) * max_bgx_per_node; bgx->max_lmac =MAX_LMAC_PER_BGX ; bgx_vnic[bgx->bgx_id] = bgx; }else {
drivers/net/ethernet/cavium/thunder/thunder_bgx.h +0 -1
@@ -22,7 +22,6 @@#define MAX_BGX_PER_CN88XX 2#define MAX_BGX_PER_CN81XX 3/* 2 BGXs + 1 RGX */ #define MAX_BGX_PER_CN83XX 4 -#define MAX_BGX_PER_NODE 4#define MAX_LMAC_PER_BGX 4#define MAX_BGX_CHANS_PER_LMAC 16#define MAX_DMAC_PER_LMAC 8
Signature · 1 line
2.7.4
PATCH v2 4/4 net: thunderx: Allow IPv6 frames with zero UDP checksum
In reply to [email protected]From: Thanneeru Srinivasulu <[email protected]>
Do not consider IPv6 frames with zero UDP checksum as frames with bad checksum and drop them.
--- drivers/net/ethernet/cavium/thunder/nicvf_queues.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/ethernet/cavium/thunder/nicvf_queues.c +4 -2
@@ -622,9 +622,11 @@ static void nicvf_rcv_queue_config(struct nicvf *nic, struct queue_set *qs,nicvf_send_msg_to_pf (nic, &mbx);if (!nic->sqs_mode && (qidx ==0 )) { -/* Enable checking L3/L4 length and TCP/UDP checksums */ +/* Enable checking L3/L4 length and TCP/UDP checksums +* Also allow IPv6 pkts with zero UDP checksum. +*/ nicvf_queue_reg_write (nic,NIC_QSET_RQ_GEN_CFG ,0 , - (BIT (24 ) |BIT (23 ) |BIT (21 ))); + (BIT (24 ) |BIT (23 ) |BIT (21 ) |BIT (20 )));nicvf_config_vlan_stripping (nic, nic->netdev->features); }
Signature · 1 line
2.7.4
David Miller
maintainerFrom: [email protected]
Date: Tue, 7 Mar 2017 18:09:07 +0530
Quoted 6 lines
From: Sunil Goutham <[email protected]>
This patch set fixes multiple issues such as IOMMU translation faults when kernel is booted with IOMMU enabled on host, incorrect MAC ID reading from ACPI tables and IPv6 UDP packet drop due to failure of checksum validation.
Series applied, thanks.