Skip to content

Commit 6ffb559

Browse files
akiyanomngyadam
authored andcommitted
Al2 5.15 Update ena driver to 2.8.6g
Signed-off-by: Arthur Kiyanovski <akiyano@amazon.com>
1 parent c375961 commit 6ffb559

File tree

3 files changed

+136
-52
lines changed

3 files changed

+136
-52
lines changed

drivers/amazon/net/ena/ena_netdev.c

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -693,16 +693,22 @@ static int ena_alloc_rx_buffer(struct ena_ring *rx_ring,
693693
return 0;
694694
}
695695

696-
static void ena_unmap_rx_buff(struct ena_ring *rx_ring,
697-
struct ena_rx_buffer *rx_info)
696+
static void ena_unmap_rx_buff_attrs(struct ena_ring *rx_ring,
697+
struct ena_rx_buffer *rx_info,
698+
unsigned long attrs)
698699
{
699700
/* LPC pages are unmapped at cache destruction */
700701
if (rx_info->is_lpc_page)
701702
return;
702703

703-
dma_unmap_page(rx_ring->dev, rx_info->dma_addr,
704-
ENA_PAGE_SIZE,
705-
DMA_BIDIRECTIONAL);
704+
ena_dma_unmap_page_attrs(rx_ring->dev, rx_info->dma_addr, ENA_PAGE_SIZE,
705+
DMA_BIDIRECTIONAL, attrs);
706+
}
707+
708+
static void ena_unmap_rx_buff(struct ena_ring *rx_ring,
709+
struct ena_rx_buffer *rx_info)
710+
{
711+
ena_unmap_rx_buff_attrs(rx_ring, rx_info, 0);
706712
}
707713

708714
static void ena_free_rx_page(struct ena_ring *rx_ring,
@@ -880,7 +886,7 @@ static void ena_free_tx_bufs(struct ena_ring *tx_ring)
880886

881887
ena_unmap_tx_buff(tx_ring, tx_info);
882888

883-
napi_consume_skb(tx_info->skb, 0);
889+
dev_kfree_skb_any(tx_info->skb);
884890
}
885891
netdev_tx_reset_queue(netdev_get_tx_queue(tx_ring->netdev,
886892
tx_ring->qid));
@@ -1012,7 +1018,7 @@ static int ena_clean_tx_irq(struct ena_ring *tx_ring, u32 budget)
10121018
skb);
10131019

10141020
tx_bytes += tx_info->total_tx_size;
1015-
napi_consume_skb(skb, budget);
1021+
dev_kfree_skb(skb);
10161022
tx_pkts++;
10171023
total_done += tx_info->tx_descs;
10181024

@@ -1063,7 +1069,7 @@ static struct sk_buff *ena_alloc_skb(struct ena_ring *rx_ring, void *first_frag,
10631069
if (!first_frag)
10641070
skb = napi_alloc_skb(rx_ring->napi, len);
10651071
else
1066-
skb = ena_build_skb(first_frag, len);
1072+
skb = build_skb(first_frag, len);
10671073
#else
10681074
if (!first_frag)
10691075
skb = napi_alloc_skb(rx_ring->napi, len);
@@ -1185,13 +1191,14 @@ static struct sk_buff *ena_rx_skb(struct ena_ring *rx_ring,
11851191
reuse_rx_buf_page = !is_xdp_loaded &&
11861192
ena_try_rx_buf_page_reuse(rx_info, buf_len, len, pkt_offset);
11871193

1194+
dma_sync_single_for_cpu(rx_ring->dev,
1195+
pre_reuse_paddr + pkt_offset,
1196+
len,
1197+
DMA_FROM_DEVICE);
1198+
11881199
if (!reuse_rx_buf_page)
1189-
ena_unmap_rx_buff(rx_ring, rx_info);
1190-
else
1191-
dma_sync_single_for_cpu(rx_ring->dev,
1192-
pre_reuse_paddr + pkt_offset,
1193-
len,
1194-
DMA_FROM_DEVICE);
1200+
ena_unmap_rx_buff_attrs(rx_ring, rx_info, ENA_DMA_ATTR_SKIP_CPU_SYNC);
1201+
11951202

11961203
skb = ena_alloc_skb(rx_ring, buf_addr, buf_len);
11971204
if (unlikely(!skb))
@@ -1249,13 +1256,14 @@ static struct sk_buff *ena_rx_skb(struct ena_ring *rx_ring,
12491256
reuse_rx_buf_page = !is_xdp_loaded &&
12501257
ena_try_rx_buf_page_reuse(rx_info, buf_len, len, pkt_offset);
12511258

1259+
dma_sync_single_for_cpu(rx_ring->dev,
1260+
pre_reuse_paddr + pkt_offset,
1261+
len,
1262+
DMA_FROM_DEVICE);
1263+
12521264
if (!reuse_rx_buf_page)
1253-
ena_unmap_rx_buff(rx_ring, rx_info);
1254-
else
1255-
dma_sync_single_for_cpu(rx_ring->dev,
1256-
pre_reuse_paddr + pkt_offset,
1257-
len,
1258-
DMA_FROM_DEVICE);
1265+
ena_unmap_rx_buff_attrs(rx_ring, rx_info, ENA_DMA_ATTR_SKIP_CPU_SYNC);
1266+
12591267

12601268
skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags, rx_info->page,
12611269
page_offset + buf_offset, len, buf_len);
@@ -3038,7 +3046,7 @@ static netdev_tx_t ena_start_xmit(struct sk_buff *skb, struct net_device *dev)
30383046
tx_info->skb = NULL;
30393047

30403048
error_drop_packet:
3041-
napi_consume_skb(skb, 0);
3049+
dev_kfree_skb(skb);
30423050
return NETDEV_TX_OK;
30433051
}
30443052

drivers/amazon/net/ena/ena_netdev.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
#define DRV_MODULE_GEN_MAJOR 2
3131
#define DRV_MODULE_GEN_MINOR 8
32-
#define DRV_MODULE_GEN_SUBMINOR 3
32+
#define DRV_MODULE_GEN_SUBMINOR 6
3333

3434
#define DRV_MODULE_NAME "ena"
3535
#ifndef DRV_MODULE_GENERATION

drivers/amazon/net/ena/kcompat.h

Lines changed: 106 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,33 @@ Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
107107
LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)
108108
#define ENA_BUSY_POLL_SUPPORT
109109
#endif
110+
111+
/* Distribution kernel version comparison macros.
112+
* Distribution kernel versioning format may be A.B.C-D.E.F and standard
113+
* KERNEL_VERSION macro covers only the first 3 subversions.
114+
* Using 20bit per subversion, as in some cases, subversion D may be a large
115+
* number (6 digits).
116+
*/
117+
#define ENA_KERNEL_VERSION_16BIT(SV1, SV2, SV3) ((SV1 << 40) | (SV2 << 20) | (SV3))
118+
#define ENA_KERNEL_VERSION_MAJOR(SV1, SV2, SV3) ENA_KERNEL_VERSION_16BIT(SV1, SV2, SV3)
119+
#define ENA_KERNEL_VERSION_MINOR(SV1, SV2, SV3) ENA_KERNEL_VERSION_16BIT(SV1, SV2, SV3)
120+
121+
#define ENA_KERNEL_VERSION_GTE(SV1, SV2, SV3, SV4, SV5, SV6) \
122+
((ENA_KERNEL_VERSION_MAJOR(ENA_KERNEL_SUBVERSION_1, ENA_KERNEL_SUBVERSION_2, ENA_KERNEL_SUBVERSION_3) > \
123+
ENA_KERNEL_VERSION_MAJOR((SV1), (SV2), (SV3))) || \
124+
(ENA_KERNEL_VERSION_MAJOR(ENA_KERNEL_SUBVERSION_1, ENA_KERNEL_SUBVERSION_2, ENA_KERNEL_SUBVERSION_3) == \
125+
ENA_KERNEL_VERSION_MAJOR((SV1), (SV2), (SV3)) && \
126+
ENA_KERNEL_VERSION_MINOR(ENA_KERNEL_SUBVERSION_4, ENA_KERNEL_SUBVERSION_5, ENA_KERNEL_SUBVERSION_6) >= \
127+
ENA_KERNEL_VERSION_MINOR((SV4), (SV5), (SV6))))
128+
129+
#define ENA_KERNEL_VERSION_LTE(SV1, SV2, SV3, SV4, SV5, SV6) \
130+
((ENA_KERNEL_VERSION_MAJOR(ENA_KERNEL_SUBVERSION_1, ENA_KERNEL_SUBVERSION_2, ENA_KERNEL_SUBVERSION_3) < \
131+
ENA_KERNEL_VERSION_MAJOR((SV1), (SV2), (SV3))) || \
132+
(ENA_KERNEL_VERSION_MAJOR(ENA_KERNEL_SUBVERSION_1, ENA_KERNEL_SUBVERSION_2, ENA_KERNEL_SUBVERSION_3) == \
133+
ENA_KERNEL_VERSION_MAJOR((SV1), (SV2), (SV3)) && \
134+
ENA_KERNEL_VERSION_MINOR(ENA_KERNEL_SUBVERSION_4, ENA_KERNEL_SUBVERSION_5, ENA_KERNEL_SUBVERSION_6) <= \
135+
ENA_KERNEL_VERSION_MINOR((SV4), (SV5), (SV6))))
136+
110137
/******************************************************************************/
111138
/************************** Ubuntu macros *************************************/
112139
/******************************************************************************/
@@ -177,7 +204,6 @@ Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
177204
#define SUSE_VERSION 0
178205
#endif /* SUSE_VERSION */
179206

180-
181207
/******************************************************************************/
182208
/**************************** RHEL macros *************************************/
183209
/******************************************************************************/
@@ -822,17 +848,32 @@ static inline void netdev_rss_key_fill(void *buffer, size_t len)
822848

823849
#if ((LINUX_VERSION_CODE < KERNEL_VERSION(4, 6 ,0)) && \
824850
!(RHEL_RELEASE_CODE && RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(7,3)))
825-
/* Linux versions 4.4.216 - 4.5 (non inclusive) back propagated page_ref_count
826-
* function from kernel 4.6. To make things more difficult, Ubuntu didn't add
827-
* these changes to its 4.4.* kernels
851+
/* Linux versions 4.4.216 - 4.5 (non inclusive) back propagated
852+
* page_ref_count() from kernel 4.6.
853+
* Ubuntu didn't add these changes to its 4.4.* kernels.
854+
* UEK added this function in kernel 4.1.12-124.43.1
855+
* Here is a figure that shows all of the cases:
856+
* Legend:
857+
* -------- page_ref_count() is present in the kernel
858+
* ******** page_ref_count() is missing in the kernel
859+
*
860+
* Distro\Kernel 4.1.12-124.43.1 4.4.216 4.5 4.6
861+
* | | | |
862+
* Upstrem kernel ***********|**************|--------|******|
863+
* | | | |
864+
* Ubuntu ***********|**************|********|******|
865+
* | | | |
866+
* UEK ***********|--------------|--------|------|
828867
*/
829-
#if !(KERNEL_VERSION(4, 4 ,216) <= LINUX_VERSION_CODE && LINUX_VERSION_CODE < KERNEL_VERSION(4, 5 ,0)) ||\
830-
defined(UBUNTU_VERSION_CODE)
868+
#if (defined(IS_UEK) && !ENA_KERNEL_VERSION_GTE(4, 1, 12, 124, 43, 1)) || \
869+
(defined(ubuntu)) || \
870+
(!defined(IS_UEK) && !defined(ubuntu) && \
871+
!(KERNEL_VERSION(4, 4, 216) <= LINUX_VERSION_CODE && LINUX_VERSION_CODE < KERNEL_VERSION(4, 5, 0)))
831872
static inline int page_ref_count(struct page *page)
832873
{
833874
return atomic_read(&page->_count);
834875
}
835-
#endif /* !(KERNEL_VERSION(4, 4 ,216) <= LINUX_VERSION_CODE && LINUX_VERSION_CODE < KERNEL_VERSION(4, 5 ,0)) */
876+
#endif /* (defined(IS_UEK) && !ENA_KERNEL_VERSION_GTE(4, 1, 12, 124, 43, 1)) ... */
836877

837878
static inline void page_ref_inc(struct page *page)
838879
{
@@ -881,32 +922,16 @@ static inline int numa_mem_id(void)
881922

882923
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 5, 0)
883924
#define ENA_LINEAR_FRAG_SUPPORTED
884-
static __always_inline struct sk_buff*
885-
ena_build_skb(void *data, unsigned int frag_size)
886-
{
887-
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 12, 0)
888-
return napi_build_skb(data, frag_size);
889-
#else
890-
return build_skb(data, frag_size);
891-
#endif
892-
}
893-
#endif
894-
895-
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 6, 0) && \
896-
!(defined(RHEL_RELEASE_CODE) && RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(7, 3)) && \
897-
!(defined(UBUNTU_VERSION_CODE) && UBUNTU_VERSION_CODE >= UBUNTU_VERSION(4, 2, 0, 42))
898-
static __always_inline
899-
void napi_consume_skb(struct sk_buff *skb, int budget)
900-
{
901-
dev_kfree_skb_any(skb);
902-
}
903925
#endif
904926

905927
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)
906928
#define ENA_NETDEV_LOGS_WITHOUT_RV
907929
#endif
908930

909-
#if defined(ENA_XDP_SUPPORT) && LINUX_VERSION_CODE < KERNEL_VERSION(5, 12, 0)
931+
#if defined(ENA_XDP_SUPPORT) && \
932+
(LINUX_VERSION_CODE < KERNEL_VERSION(5, 12, 0) && \
933+
!(defined(SUSE_VERSION) && (SUSE_VERSION == 15 && SUSE_PATCHLEVEL == 3) && \
934+
ENA_KERNEL_VERSION_GTE(5, 3, 18, 150300, 59, 49)))
910935
static __always_inline void
911936
xdp_init_buff(struct xdp_buff *xdp, u32 frame_sz, struct xdp_rxq_info *rxq)
912937
{
@@ -928,7 +953,7 @@ xdp_prepare_buff(struct xdp_buff *xdp, unsigned char *hard_start,
928953
xdp->data_meta = meta_valid ? data : data + 1;
929954
}
930955

931-
#endif /* defined(ENA_XDP_SUPPORT) && LINUX_VERSION_CODE <= KERNEL_VERSION(5, 12, 0) */
956+
#endif /* defined(ENA_XDP_SUPPORT) && (LINUX_VERSION_CODE <= KERNEL_VERSION(5, 12, 0) && !SUSE_VERSION(...)) */
932957

933958
#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 13, 0)
934959
#define ethtool_sprintf(data, fmt, args...) \
@@ -944,7 +969,9 @@ xdp_prepare_buff(struct xdp_buff *xdp, unsigned char *hard_start,
944969

945970
#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 15, 0) && \
946971
!(defined(RHEL_RELEASE_CODE) && RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(8, 6)) && \
947-
!(defined(SUSE_VERSION) && (SUSE_VERSION == 15 && SUSE_PATCHLEVEL >= 4))
972+
!(defined(SUSE_VERSION) && (SUSE_VERSION == 15 && SUSE_PATCHLEVEL >= 4)) && \
973+
!(defined(SUSE_VERSION) && (SUSE_VERSION == 15 && SUSE_PATCHLEVEL == 3) && \
974+
ENA_KERNEL_VERSION_GTE(5, 3, 18, 150300, 59, 43))
948975
static inline void eth_hw_addr_set(struct net_device *dev, const u8 *addr)
949976
{
950977
memcpy(dev->dev_addr, addr, ETH_ALEN);
@@ -1065,7 +1092,8 @@ static inline void ena_netif_napi_add(struct net_device *dev,
10651092
struct napi_struct *napi,
10661093
int (*poll)(struct napi_struct *, int))
10671094
{
1068-
#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0)
1095+
#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0)) && \
1096+
!(RHEL_RELEASE_CODE && (RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(9, 2)))
10691097
#ifndef NAPI_POLL_WEIGHT
10701098
#define NAPI_POLL_WEIGHT 64
10711099
#endif
@@ -1075,4 +1103,52 @@ static inline void ena_netif_napi_add(struct net_device *dev,
10751103
#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0) */
10761104
}
10771105

1106+
#if (RHEL_RELEASE_CODE && (RHEL_RELEASE_CODE <= RHEL_RELEASE_VERSION(7, 4))) || \
1107+
(defined(UBUNTU_VERSION_CODE) && UBUNTU_VERSION_CODE < UBUNTU_VERSION(4, 5, 0, 0)) || \
1108+
(defined(IS_UEK) && !ENA_KERNEL_VERSION_GTE(4, 1, 12, 105, 0, 0))
1109+
static inline void dma_unmap_page_attrs(struct device *dev,
1110+
dma_addr_t addr, size_t size,
1111+
enum dma_data_direction dir,
1112+
struct dma_attrs *attrs)
1113+
{
1114+
struct dma_map_ops *ops = get_dma_ops(dev);
1115+
1116+
BUG_ON(!valid_dma_direction(dir));
1117+
if (ops->unmap_page)
1118+
ops->unmap_page(dev, addr, size, dir, attrs);
1119+
debug_dma_unmap_page(dev, addr, size, dir, false);
1120+
}
1121+
#endif /* RHEL_RELEASE_CODE && (RHEL_RELEASE_CODE <= RHEL_RELEASE_VERSION(7, 4)) */
1122+
1123+
#if (RHEL_RELEASE_CODE && (RHEL_RELEASE_CODE <= RHEL_RELEASE_VERSION(7, 9)) && \
1124+
(RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(7, 0)) && \
1125+
(LINUX_VERSION_CODE != KERNEL_VERSION(4, 14, 0))) || \
1126+
(defined(UBUNTU_VERSION_CODE) && UBUNTU_VERSION_CODE < UBUNTU_VERSION(4, 5, 0, 0)) || \
1127+
(defined(IS_UEK) && LINUX_VERSION_CODE < KERNEL_VERSION(4, 1, 13))
1128+
#define ENA_DMA_ATTR_SKIP_CPU_SYNC (1 << DMA_ATTR_SKIP_CPU_SYNC)
1129+
#elif (RHEL_RELEASE_CODE && (RHEL_RELEASE_CODE <= RHEL_RELEASE_VERSION(6, 10)))
1130+
#define ENA_DMA_ATTR_SKIP_CPU_SYNC 0
1131+
#else
1132+
#define ENA_DMA_ATTR_SKIP_CPU_SYNC DMA_ATTR_SKIP_CPU_SYNC
1133+
#endif
1134+
1135+
static inline void ena_dma_unmap_page_attrs(struct device *dev,
1136+
dma_addr_t addr, size_t size,
1137+
enum dma_data_direction dir,
1138+
unsigned long attrs)
1139+
{
1140+
#if (RHEL_RELEASE_CODE && (RHEL_RELEASE_CODE <= RHEL_RELEASE_VERSION(7, 9)) && \
1141+
(LINUX_VERSION_CODE != KERNEL_VERSION(4, 14, 0))) || \
1142+
(defined(UBUNTU_VERSION_CODE) && UBUNTU_VERSION_CODE < UBUNTU_VERSION(4, 5, 0, 0)) || \
1143+
(defined(IS_UEK) && LINUX_VERSION_CODE < KERNEL_VERSION(4, 1, 13))
1144+
struct dma_attrs dma_attrs;
1145+
1146+
init_dma_attrs(&dma_attrs);
1147+
dma_attrs.flags[0] = attrs;
1148+
dma_unmap_page_attrs(dev, addr, size, dir, &dma_attrs);
1149+
#else
1150+
dma_unmap_page_attrs(dev, addr, size, dir, attrs);
1151+
#endif
1152+
}
1153+
10781154
#endif /* _KCOMPAT_H_ */

0 commit comments

Comments
 (0)