Skip to content

Commit c061161

Browse files
yishachepuranjaymohan
authored andcommitted
ena: Update to 2.6.0
Sourced from upstream git repo: https://github.com/amzn/amzn-drivers/ Change Log from Upstream: 2.5.0 -> 2.6.0 **New Features** * Add "capabilities" field to negotiate device capabilities * Add support for kernel 5.14 * Allow the device to signal the driver if features renogotiation is required **Bug Fixes** * Fix XDP packet fowarding on 6th generaion instances * Prevent device reset when device isn't responsive **Minor Changes** * Move Local Page Cache (LPC) code to a separate file * Reset device when receiving wrong request id on RX * Cosmetic changes and code restructuring * Fix typo in README * Remove redundant code Signed-off-by: Ethan Chen <yishache@amazon.com>
1 parent 9e54b40 commit c061161

File tree

11 files changed

+631
-521
lines changed

11 files changed

+631
-521
lines changed

drivers/amazon/net/ena/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
obj-$(CONFIG_AMAZON_ENA_ETHERNET) += ena.o
88

99
ena-y := ena_netdev.o ena_com.o ena_eth_com.o ena_ethtool.o net_dim.o \
10-
dim.o
10+
dim.o ena_lpc.o
1111

1212
ena-$(CONFIG_SYSFS) += ena_sysfs.o

drivers/amazon/net/ena/ena_admin_defs.h

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ enum ena_admin_aq_feature_id {
5353
ENA_ADMIN_FEATURES_OPCODE_NUM = 32,
5454
};
5555

56+
/* device capabilities */
57+
enum ena_admin_aq_caps_id {
58+
ENA_ADMIN_ENI_STATS = 0,
59+
};
60+
5661
enum ena_admin_placement_policy_type {
5762
/* descriptors and headers are in host memory */
5863
ENA_ADMIN_PLACEMENT_POLICY_HOST = 1,
@@ -460,7 +465,10 @@ struct ena_admin_device_attr_feature_desc {
460465
*/
461466
u32 supported_features;
462467

463-
u32 reserved3;
468+
/* bitmap of ena_admin_aq_caps_id, which represents device
469+
* capabilities.
470+
*/
471+
u32 capabilities;
464472

465473
/* Indicates how many bits are used physical address access. */
466474
u32 phys_addr_width;
@@ -1061,7 +1069,8 @@ enum ena_admin_aenq_group {
10611069
ENA_ADMIN_WARNING = 2,
10621070
ENA_ADMIN_NOTIFICATION = 3,
10631071
ENA_ADMIN_KEEP_ALIVE = 4,
1064-
ENA_ADMIN_AENQ_GROUPS_NUM = 5,
1072+
ENA_ADMIN_REFRESH_CAPABILITIES = 5,
1073+
ENA_ADMIN_AENQ_GROUPS_NUM = 6,
10651074
};
10661075

10671076
enum ena_admin_aenq_notification_syndrome {

drivers/amazon/net/ena/ena_com.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -865,7 +865,7 @@ static u32 ena_com_reg_bar_read32(struct ena_com_dev *ena_dev, u16 offset)
865865

866866
if (unlikely(i == timeout)) {
867867
netdev_err(ena_dev->net_device,
868-
"Reading reg failed for timeout. expected: req id[%hu] offset[%hu] actual: req id[%hu] offset[%hu]\n",
868+
"Reading reg failed for timeout. expected: req id[%u] offset[%u] actual: req id[%u] offset[%u]\n",
869869
mmio_read->seq_num, offset, read_resp->req_id,
870870
read_resp->reg_off);
871871
ret = ENA_MMIO_READ_TIMEOUT;
@@ -1979,6 +1979,7 @@ int ena_com_get_dev_attr_feat(struct ena_com_dev *ena_dev,
19791979
sizeof(get_resp.u.dev_attr));
19801980

19811981
ena_dev->supported_features = get_resp.u.dev_attr.supported_features;
1982+
ena_dev->capabilities = get_resp.u.dev_attr.capabilities;
19821983

19831984
if (ena_dev->supported_features & BIT(ENA_ADMIN_MAX_QUEUES_EXT)) {
19841985
rc = ena_com_get_feature(ena_dev, &get_resp,
@@ -1987,7 +1988,8 @@ int ena_com_get_dev_attr_feat(struct ena_com_dev *ena_dev,
19871988
if (rc)
19881989
return rc;
19891990

1990-
if (get_resp.u.max_queue_ext.version != ENA_FEATURE_MAX_QUEUE_EXT_VER)
1991+
if (get_resp.u.max_queue_ext.version !=
1992+
ENA_FEATURE_MAX_QUEUE_EXT_VER)
19911993
return -EINVAL;
19921994

19931995
memcpy(&get_feat_ctx->max_queue_ext, &get_resp.u.max_queue_ext,
@@ -2233,6 +2235,13 @@ int ena_com_get_eni_stats(struct ena_com_dev *ena_dev,
22332235
struct ena_com_stats_ctx ctx;
22342236
int ret;
22352237

2238+
if (!ena_com_get_cap(ena_dev, ENA_ADMIN_ENI_STATS)) {
2239+
netdev_err(ena_dev->net_device,
2240+
"Capability %d isn't supported\n",
2241+
ENA_ADMIN_ENI_STATS);
2242+
return -EOPNOTSUPP;
2243+
}
2244+
22362245
memset(&ctx, 0x0, sizeof(ctx));
22372246
ret = ena_get_dev_stats(ena_dev, &ctx, ENA_ADMIN_GET_STATS_TYPE_ENI);
22382247
if (likely(ret == 0))
@@ -2407,7 +2416,7 @@ int ena_com_fill_hash_function(struct ena_com_dev *ena_dev,
24072416
if (key) {
24082417
if (key_len != sizeof(hash_key->key)) {
24092418
netdev_err(ena_dev->net_device,
2410-
"key len (%hu) doesn't equal the supported size (%zu)\n",
2419+
"key len (%u) doesn't equal the supported size (%zu)\n",
24112420
key_len, sizeof(hash_key->key));
24122421
return -EINVAL;
24132422
}

drivers/amazon/net/ena/ena_com.h

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ struct ena_com_io_cq {
125125

126126
/* holds the number of cdesc of the current packet */
127127
u16 cur_rx_pkt_cdesc_count;
128-
/* save the firt cdesc idx of the current packet */
128+
/* save the first cdesc idx of the current packet */
129129
u16 cur_rx_pkt_cdesc_start_idx;
130130

131131
u16 q_depth;
@@ -318,6 +318,7 @@ struct ena_com_dev {
318318

319319
struct ena_rss rss;
320320
u32 supported_features;
321+
u32 capabilities;
321322
u32 dma_addr_bits;
322323

323324
struct ena_host_attribute host_attr;
@@ -983,6 +984,18 @@ static inline void ena_com_disable_adaptive_moderation(struct ena_com_dev *ena_d
983984
ena_dev->adaptive_coalescing = false;
984985
}
985986

987+
/* ena_com_get_cap - query whether device supports a capability.
988+
* @ena_dev: ENA communication layer struct
989+
* @cap_id: enum value representing the capability
990+
*
991+
* @return - true if capability is supported or false otherwise
992+
*/
993+
static inline bool ena_com_get_cap(struct ena_com_dev *ena_dev,
994+
enum ena_admin_aq_caps_id cap_id)
995+
{
996+
return !!(ena_dev->capabilities & BIT(cap_id));
997+
}
998+
986999
/* ena_com_update_intr_reg - Prepare interrupt register
9871000
* @intr_reg: interrupt register to update.
9881001
* @rx_delay_interval: Rx interval in usecs

drivers/amazon/net/ena/ena_eth_com.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -328,9 +328,6 @@ static int ena_com_create_and_store_tx_meta_desc(struct ena_com_io_sq *io_sq,
328328
* compare it to the stored version, just create the meta
329329
*/
330330
if (io_sq->disable_meta_caching) {
331-
if (unlikely(!ena_tx_ctx->meta_valid))
332-
return -EINVAL;
333-
334331
*have_meta = true;
335332
return ena_com_create_meta(io_sq, ena_meta);
336333
}

drivers/amazon/net/ena/ena_ethtool.c

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,7 @@ static const struct ena_stats ena_stats_ena_com_strings[] = {
120120
#define ENA_STATS_ARRAY_TX ARRAY_SIZE(ena_stats_tx_strings)
121121
#define ENA_STATS_ARRAY_RX ARRAY_SIZE(ena_stats_rx_strings)
122122
#define ENA_STATS_ARRAY_ENA_COM ARRAY_SIZE(ena_stats_ena_com_strings)
123-
#define ENA_STATS_ARRAY_ENI(adapter) \
124-
(ARRAY_SIZE(ena_stats_eni_strings) * (adapter)->eni_stats_supported)
123+
#define ENA_STATS_ARRAY_ENI(adapter) ARRAY_SIZE(ena_stats_eni_strings)
125124

126125
static const char ena_priv_flags_strings[][ETH_GSTRING_LEN] = {
127126
#define ENA_PRIV_FLAGS_LPC BIT(0)
@@ -230,8 +229,9 @@ static void ena_get_ethtool_stats(struct net_device *netdev,
230229
u64 *data)
231230
{
232231
struct ena_adapter *adapter = netdev_priv(netdev);
232+
struct ena_com_dev *dev = adapter->ena_dev;
233233

234-
ena_get_stats(adapter, data, adapter->eni_stats_supported);
234+
ena_get_stats(adapter, data, ena_com_get_cap(dev, ENA_ADMIN_ENI_STATS));
235235
}
236236

237237
static int ena_get_sw_stats_count(struct ena_adapter *adapter)
@@ -243,7 +243,9 @@ static int ena_get_sw_stats_count(struct ena_adapter *adapter)
243243

244244
static int ena_get_hw_stats_count(struct ena_adapter *adapter)
245245
{
246-
return ENA_STATS_ARRAY_ENI(adapter);
246+
bool supported = ena_com_get_cap(adapter->ena_dev, ENA_ADMIN_ENI_STATS);
247+
248+
return ENA_STATS_ARRAY_ENI(adapter) * supported;
247249
}
248250

249251
int ena_get_sset_count(struct net_device *netdev, int sset)
@@ -273,10 +275,10 @@ static void ena_queue_strings(struct ena_adapter *adapter, u8 **data)
273275
for (j = 0; j < ENA_STATS_ARRAY_TX; j++) {
274276
ena_stats = &ena_stats_tx_strings[j];
275277

276-
snprintf(*data, ETH_GSTRING_LEN,
277-
"queue_%u_%s_%s", i,
278-
is_xdp ? "xdp_tx" : "tx", ena_stats->name);
279-
(*data) += ETH_GSTRING_LEN;
278+
ethtool_sprintf(data,
279+
"queue_%u_%s_%s", i,
280+
is_xdp ? "xdp_tx" : "tx",
281+
ena_stats->name);
280282
}
281283

282284
if (!is_xdp) {
@@ -286,9 +288,9 @@ static void ena_queue_strings(struct ena_adapter *adapter, u8 **data)
286288
for (j = 0; j < ENA_STATS_ARRAY_RX; j++) {
287289
ena_stats = &ena_stats_rx_strings[j];
288290

289-
snprintf(*data, ETH_GSTRING_LEN,
290-
"queue_%u_rx_%s", i, ena_stats->name);
291-
(*data) += ETH_GSTRING_LEN;
291+
ethtool_sprintf(data,
292+
"queue_%u_rx_%s", i,
293+
ena_stats->name);
292294
}
293295
}
294296
}
@@ -302,9 +304,8 @@ static void ena_com_dev_strings(u8 **data)
302304
for (i = 0; i < ENA_STATS_ARRAY_ENA_COM; i++) {
303305
ena_stats = &ena_stats_ena_com_strings[i];
304306

305-
snprintf(*data, ETH_GSTRING_LEN,
306-
"ena_admin_q_%s", ena_stats->name);
307-
(*data) += ETH_GSTRING_LEN;
307+
ethtool_sprintf(data,
308+
"ena_admin_q_%s", ena_stats->name);
308309
}
309310
}
310311

@@ -317,15 +318,13 @@ static void ena_get_strings(struct ena_adapter *adapter,
317318

318319
for (i = 0; i < ENA_STATS_ARRAY_GLOBAL; i++) {
319320
ena_stats = &ena_stats_global_strings[i];
320-
memcpy(data, ena_stats->name, ETH_GSTRING_LEN);
321-
data += ETH_GSTRING_LEN;
321+
ethtool_sprintf(&data, ena_stats->name);
322322
}
323323

324324
if (eni_stats_needed) {
325325
for (i = 0; i < ENA_STATS_ARRAY_ENI(adapter); i++) {
326326
ena_stats = &ena_stats_eni_strings[i];
327-
memcpy(data, ena_stats->name, ETH_GSTRING_LEN);
328-
data += ETH_GSTRING_LEN;
327+
ethtool_sprintf(&data, ena_stats->name);
329328
}
330329
}
331330

@@ -338,10 +337,11 @@ static void ena_get_ethtool_strings(struct net_device *netdev,
338337
u8 *data)
339338
{
340339
struct ena_adapter *adapter = netdev_priv(netdev);
340+
struct ena_com_dev *dev = adapter->ena_dev;
341341

342342
switch (sset) {
343343
case ETH_SS_STATS:
344-
ena_get_strings(adapter, data, adapter->eni_stats_supported);
344+
ena_get_strings(adapter, data, ena_com_get_cap(dev, ENA_ADMIN_ENI_STATS));
345345
break;
346346
case ETH_SS_PRIV_FLAGS:
347347
memcpy(data, ena_priv_flags_strings, sizeof(ena_priv_flags_strings));

0 commit comments

Comments
 (0)