History

nfp: remove padding in nfp_nfdk_tx_desc

NFDK firmware supports 48-bit dma addressing and parses 16 high bits of dma addresses. In nfp_nfdk_tx_desc, dma related structure and tso related structure are union. When "mss" be filled with nonzero value due to enable tso, the memory used by "padding" may be also filled. Then, firmware may parse wrong dma addresses which causes TX watchdog timeout problem. This patch removes padding and unifies the dma_addr_hi bits with the one in firmware. nfp_nfdk_tx_desc_set_dma_addr is also added to match this change.

Fei Qin committed 4 years ago

Commit c6fbbf11 parent 7d8a3a43 files · +17 −9Browse files

Unified · Split

3 files
  1. drivers/net/ethernet/netronome/nfp/nfdk/dp.c +6 −6
  2. drivers/net/ethernet/netronome/nfp/nfdk/nfdk.h +1 −2
  3. drivers/net/ethernet/netronome/nfp/nfp_net.h +10 −1
drivers/net/ethernet/netronome/nfp/nfdk/dp.c+6−6
@@ -314,7 +314,7 @@ netdev_tx_t nfp_nfdk_tx(struct sk_buff *skb, struct net_device *netdev) · 313 unmodified lines
314 FIELD_PREP(NFDK_DESC_TX_TYPE_HEAD, type);314 FIELD_PREP(NFDK_DESC_TX_TYPE_HEAD, type);
315 315
316 txd->dma_len_type = cpu_to_le16(dlen_type);316 txd->dma_len_type = cpu_to_le16(dlen_type);
317 nfp_desc_set_dma_addr(txd, dma_addr);317 nfp_nfdk_tx_desc_set_dma_addr(txd, dma_addr);
318 318
319 /* starts at bit 0 */319 /* starts at bit 0 */
320 BUILD_BUG_ON(!(NFDK_DESC_TX_DMA_LEN_HEAD & 1));320 BUILD_BUG_ON(!(NFDK_DESC_TX_DMA_LEN_HEAD & 1));
@@ -339,7 +339,7 @@ netdev_tx_t nfp_nfdk_tx(struct sk_buff *skb, struct net_device *netdev) · 18 unmodified lines
339 dlen_type = FIELD_PREP(NFDK_DESC_TX_DMA_LEN, dma_len);339 dlen_type = FIELD_PREP(NFDK_DESC_TX_DMA_LEN, dma_len);
340 340
341 txd->dma_len_type = cpu_to_le16(dlen_type);341 txd->dma_len_type = cpu_to_le16(dlen_type);
342 nfp_desc_set_dma_addr(txd, dma_addr);342 nfp_nfdk_tx_desc_set_dma_addr(txd, dma_addr);
343 343
344 dma_len -= dlen_type;344 dma_len -= dlen_type;
345 dma_addr += dlen_type + 1;345 dma_addr += dlen_type + 1;
@@ -929,7 +929,7 @@ nfp_nfdk_tx_xdp_buf(struct nfp_net_dp *dp, struct nfp_net_rx_ring *rx_ring, · 583 unmodified lines
929 FIELD_PREP(NFDK_DESC_TX_TYPE_HEAD, type);929 FIELD_PREP(NFDK_DESC_TX_TYPE_HEAD, type);
930 930
931 txd->dma_len_type = cpu_to_le16(dlen_type);931 txd->dma_len_type = cpu_to_le16(dlen_type);
932 nfp_desc_set_dma_addr(txd, dma_addr);932 nfp_nfdk_tx_desc_set_dma_addr(txd, dma_addr);
933 933
934 tmp_dlen = dlen_type & NFDK_DESC_TX_DMA_LEN_HEAD;934 tmp_dlen = dlen_type & NFDK_DESC_TX_DMA_LEN_HEAD;
935 dma_len -= tmp_dlen;935 dma_len -= tmp_dlen;
@@ -940,7 +940,7 @@ nfp_nfdk_tx_xdp_buf(struct nfp_net_dp *dp, struct nfp_net_rx_ring *rx_ring, · 4 unmodified lines
940 dma_len -= 1;940 dma_len -= 1;
941 dlen_type = FIELD_PREP(NFDK_DESC_TX_DMA_LEN, dma_len);941 dlen_type = FIELD_PREP(NFDK_DESC_TX_DMA_LEN, dma_len);
942 txd->dma_len_type = cpu_to_le16(dlen_type);942 txd->dma_len_type = cpu_to_le16(dlen_type);
943 nfp_desc_set_dma_addr(txd, dma_addr);943 nfp_nfdk_tx_desc_set_dma_addr(txd, dma_addr);
944 944
945 dlen_type &= NFDK_DESC_TX_DMA_LEN;945 dlen_type &= NFDK_DESC_TX_DMA_LEN;
946 dma_len -= dlen_type;946 dma_len -= dlen_type;
@@ -1332,7 +1332,7 @@ nfp_nfdk_ctrl_tx_one(struct nfp_net *nn, struct nfp_net_r_vector *r_vec, · 385 unmodified lines
1332 FIELD_PREP(NFDK_DESC_TX_TYPE_HEAD, type);1332 FIELD_PREP(NFDK_DESC_TX_TYPE_HEAD, type);
1333 1333
1334 txd->dma_len_type = cpu_to_le16(dlen_type);1334 txd->dma_len_type = cpu_to_le16(dlen_type);
1335 nfp_desc_set_dma_addr(txd, dma_addr);1335 nfp_nfdk_tx_desc_set_dma_addr(txd, dma_addr);
1336 1336
1337 tmp_dlen = dlen_type & NFDK_DESC_TX_DMA_LEN_HEAD;1337 tmp_dlen = dlen_type & NFDK_DESC_TX_DMA_LEN_HEAD;
1338 dma_len -= tmp_dlen;1338 dma_len -= tmp_dlen;
@@ -1343,7 +1343,7 @@ nfp_nfdk_ctrl_tx_one(struct nfp_net *nn, struct nfp_net_r_vector *r_vec, · 4 unmodified lines
1343 dma_len -= 1;1343 dma_len -= 1;
1344 dlen_type = FIELD_PREP(NFDK_DESC_TX_DMA_LEN, dma_len);1344 dlen_type = FIELD_PREP(NFDK_DESC_TX_DMA_LEN, dma_len);
1345 txd->dma_len_type = cpu_to_le16(dlen_type);1345 txd->dma_len_type = cpu_to_le16(dlen_type);
1346 nfp_desc_set_dma_addr(txd, dma_addr);1346 nfp_nfdk_tx_desc_set_dma_addr(txd, dma_addr);
1347 1347
1348 dlen_type &= NFDK_DESC_TX_DMA_LEN;1348 dlen_type &= NFDK_DESC_TX_DMA_LEN;
1349 dma_len -= dlen_type;1349 dma_len -= dlen_type;
drivers/net/ethernet/netronome/nfp/nfdk/nfdk.h+1−2
@@ -46,8 +46,7 @@ · 45 unmodified lines
46struct nfp_nfdk_tx_desc {46struct nfp_nfdk_tx_desc {
47 union {47 union {
48 struct {48 struct {
49 u8 dma_addr_hi; /* High bits of host buf address */49 __le16 dma_addr_hi; /* High bits of host buf address */
50 u8 padding; /* Must be zero */
51 __le16 dma_len_type; /* Length to DMA for this desc */50 __le16 dma_len_type; /* Length to DMA for this desc */
52 __le32 dma_addr_lo; /* Low 32bit of host buf addr */51 __le32 dma_addr_lo; /* Low 32bit of host buf addr */
53 };52 };
drivers/net/ethernet/netronome/nfp/nfp_net.h+10−1
@@ -117,13 +117,22 @@ struct nfp_nfdk_tx_buf; · 116 unmodified lines
117/* Convenience macro for writing dma address into RX/TX descriptors */117/* Convenience macro for writing dma address into RX/TX descriptors */
118#define nfp_desc_set_dma_addr(desc, dma_addr) \118#define nfp_desc_set_dma_addr(desc, dma_addr) \
119 do { \119 do { \
120 __typeof(desc) __d = (desc); \120 __typeof__(desc) __d = (desc); \
121 dma_addr_t __addr = (dma_addr); \121 dma_addr_t __addr = (dma_addr); \
122 \122 \
123 __d->dma_addr_lo = cpu_to_le32(lower_32_bits(__addr)); \123 __d->dma_addr_lo = cpu_to_le32(lower_32_bits(__addr)); \
124 __d->dma_addr_hi = upper_32_bits(__addr) & 0xff; \124 __d->dma_addr_hi = upper_32_bits(__addr) & 0xff; \
125 } while (0)125 } while (0)
126 126
127#define nfp_nfdk_tx_desc_set_dma_addr(desc, dma_addr) \
128 do { \
129 __typeof__(desc) __d = (desc); \
130 dma_addr_t __addr = (dma_addr); \
131 \
132 __d->dma_addr_hi = cpu_to_le16(upper_32_bits(__addr) & 0xff); \
133 __d->dma_addr_lo = cpu_to_le32(lower_32_bits(__addr)); \
134 } while (0)
135
127/**136/**
128 * struct nfp_net_tx_ring - TX ring structure137 * struct nfp_net_tx_ring - TX ring structure
129 * @r_vec: Back pointer to ring vector structure138 * @r_vec: Back pointer to ring vector structure

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t