Skip to content

Commit d1a2250

Browse files
committed
Merge branch 'Enhance-current-features-in-ena-driver'
Sameeh Jubran says: ==================== Enhance current features in ena driver Difference from v2: * dropped patch "net: ena: move llq configuration from ena_probe to ena_device_init()" * reworked patch ""net: ena: implement ena_com_get_admin_polling_mode() to drop the prototype Difference from v1: * reodered paches #1 and #2. * dropped adding Rx/Tx drops to ethtool in patch #8 V1: This patchset introduces the following: * minor changes to RSS feature * add total rx and tx drop counter * add unmask_interrupt counter for ethtool statistics * add missing implementation for ena_com_get_admin_polling_mode() * some minor code clean-up and cosmetics * use SHUTDOWN as reset reason when closing interface ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 5889a62 + 77a651f commit d1a2250

File tree

6 files changed

+105
-70
lines changed

6 files changed

+105
-70
lines changed

drivers/net/ethernet/amazon/ena/ena_admin_defs.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,10 @@ struct ena_admin_basic_stats {
404404
u32 rx_drops_low;
405405

406406
u32 rx_drops_high;
407+
408+
u32 tx_drops_low;
409+
410+
u32 tx_drops_high;
407411
};
408412

409413
struct ena_admin_acq_get_stats_resp {
@@ -1017,6 +1021,10 @@ struct ena_admin_aenq_keep_alive_desc {
10171021
u32 rx_drops_low;
10181022

10191023
u32 rx_drops_high;
1024+
1025+
u32 tx_drops_low;
1026+
1027+
u32 tx_drops_high;
10201028
};
10211029

10221030
struct ena_admin_ena_mmio_req_read_less_resp {

drivers/net/ethernet/amazon/ena/ena_com.c

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1067,16 +1067,10 @@ static void ena_com_hash_key_fill_default_key(struct ena_com_dev *ena_dev)
10671067
static int ena_com_hash_key_allocate(struct ena_com_dev *ena_dev)
10681068
{
10691069
struct ena_rss *rss = &ena_dev->rss;
1070-
struct ena_admin_get_feat_resp get_resp;
1071-
int rc;
10721070

1073-
rc = ena_com_get_feature_ex(ena_dev, &get_resp,
1074-
ENA_ADMIN_RSS_HASH_FUNCTION,
1075-
ena_dev->rss.hash_key_dma_addr,
1076-
sizeof(ena_dev->rss.hash_key), 0);
1077-
if (unlikely(rc)) {
1071+
if (!ena_com_check_supported_feature_id(ena_dev,
1072+
ENA_ADMIN_RSS_HASH_FUNCTION))
10781073
return -EOPNOTSUPP;
1079-
}
10801074

10811075
rss->hash_key =
10821076
dma_alloc_coherent(ena_dev->dmadev, sizeof(*rss->hash_key),
@@ -2286,6 +2280,7 @@ int ena_com_fill_hash_function(struct ena_com_dev *ena_dev,
22862280
struct ena_admin_get_feat_resp get_resp;
22872281
struct ena_admin_feature_rss_flow_hash_control *hash_key =
22882282
rss->hash_key;
2283+
enum ena_admin_hash_functions old_func;
22892284
int rc;
22902285

22912286
/* Make sure size is a mult of DWs */
@@ -2325,26 +2320,27 @@ int ena_com_fill_hash_function(struct ena_com_dev *ena_dev,
23252320
return -EINVAL;
23262321
}
23272322

2323+
old_func = rss->hash_func;
23282324
rss->hash_func = func;
23292325
rc = ena_com_set_hash_function(ena_dev);
23302326

23312327
/* Restore the old function */
23322328
if (unlikely(rc))
2333-
ena_com_get_hash_function(ena_dev, NULL, NULL);
2329+
rss->hash_func = old_func;
23342330

23352331
return rc;
23362332
}
23372333

23382334
int ena_com_get_hash_function(struct ena_com_dev *ena_dev,
2339-
enum ena_admin_hash_functions *func,
2340-
u8 *key)
2335+
enum ena_admin_hash_functions *func)
23412336
{
23422337
struct ena_rss *rss = &ena_dev->rss;
23432338
struct ena_admin_get_feat_resp get_resp;
2344-
struct ena_admin_feature_rss_flow_hash_control *hash_key =
2345-
rss->hash_key;
23462339
int rc;
23472340

2341+
if (unlikely(!func))
2342+
return -EINVAL;
2343+
23482344
rc = ena_com_get_feature_ex(ena_dev, &get_resp,
23492345
ENA_ADMIN_RSS_HASH_FUNCTION,
23502346
rss->hash_key_dma_addr,
@@ -2357,8 +2353,15 @@ int ena_com_get_hash_function(struct ena_com_dev *ena_dev,
23572353
if (rss->hash_func)
23582354
rss->hash_func--;
23592355

2360-
if (func)
2361-
*func = rss->hash_func;
2356+
*func = rss->hash_func;
2357+
2358+
return 0;
2359+
}
2360+
2361+
int ena_com_get_hash_key(struct ena_com_dev *ena_dev, u8 *key)
2362+
{
2363+
struct ena_admin_feature_rss_flow_hash_control *hash_key =
2364+
ena_dev->rss.hash_key;
23622365

23632366
if (key)
23642367
memcpy(key, hash_key->key, (size_t)(hash_key->keys_num) << 2);
@@ -2641,10 +2644,10 @@ int ena_com_rss_init(struct ena_com_dev *ena_dev, u16 indr_tbl_log_size)
26412644
* ignore this error and have indirection table support only.
26422645
*/
26432646
rc = ena_com_hash_key_allocate(ena_dev);
2644-
if (unlikely(rc) && rc != -EOPNOTSUPP)
2645-
goto err_hash_key;
2646-
else if (rc != -EOPNOTSUPP)
2647+
if (likely(!rc))
26472648
ena_com_hash_key_fill_default_key(ena_dev);
2649+
else if (rc != -EOPNOTSUPP)
2650+
goto err_hash_key;
26482651

26492652
rc = ena_com_hash_ctrl_init(ena_dev);
26502653
if (unlikely(rc))

drivers/net/ethernet/amazon/ena/ena_com.h

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@
5454
#undef pr_fmt
5555
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
5656

57-
#define ENA_MAX_NUM_IO_QUEUES 128U
57+
#define ENA_MAX_NUM_IO_QUEUES 128U
5858
/* We need to queues for each IO (on for Tx and one for Rx) */
59-
#define ENA_TOTAL_NUM_QUEUES (2 * (ENA_MAX_NUM_IO_QUEUES))
59+
#define ENA_TOTAL_NUM_QUEUES (2 * (ENA_MAX_NUM_IO_QUEUES))
6060

6161
#define ENA_MAX_HANDLERS 256
6262

@@ -73,13 +73,13 @@
7373
/*****************************************************************************/
7474
/* ENA adaptive interrupt moderation settings */
7575

76-
#define ENA_INTR_INITIAL_TX_INTERVAL_USECS 64
77-
#define ENA_INTR_INITIAL_RX_INTERVAL_USECS 0
78-
#define ENA_DEFAULT_INTR_DELAY_RESOLUTION 1
76+
#define ENA_INTR_INITIAL_TX_INTERVAL_USECS 64
77+
#define ENA_INTR_INITIAL_RX_INTERVAL_USECS 0
78+
#define ENA_DEFAULT_INTR_DELAY_RESOLUTION 1
7979

80-
#define ENA_HW_HINTS_NO_TIMEOUT 0xFFFF
80+
#define ENA_HW_HINTS_NO_TIMEOUT 0xFFFF
8181

82-
#define ENA_FEATURE_MAX_QUEUE_EXT_VER 1
82+
#define ENA_FEATURE_MAX_QUEUE_EXT_VER 1
8383

8484
struct ena_llq_configurations {
8585
enum ena_admin_llq_header_location llq_header_location;
@@ -501,18 +501,6 @@ bool ena_com_get_admin_running_state(struct ena_com_dev *ena_dev);
501501
*/
502502
void ena_com_set_admin_polling_mode(struct ena_com_dev *ena_dev, bool polling);
503503

504-
/* ena_com_set_admin_polling_mode - Get the admin completion queue polling mode
505-
* @ena_dev: ENA communication layer struct
506-
*
507-
* Get the admin completion mode.
508-
* If polling mode is on, ena_com_execute_admin_command will perform a
509-
* polling on the admin completion queue for the commands completion,
510-
* otherwise it will wait on wait event.
511-
*
512-
* @return state
513-
*/
514-
bool ena_com_get_ena_admin_polling_mode(struct ena_com_dev *ena_dev);
515-
516504
/* ena_com_set_admin_auto_polling_mode - Enable autoswitch to polling mode
517505
* @ena_dev: ENA communication layer struct
518506
* @polling: Enable/Disable polling mode
@@ -695,23 +683,32 @@ int ena_com_fill_hash_function(struct ena_com_dev *ena_dev,
695683
*/
696684
int ena_com_set_hash_function(struct ena_com_dev *ena_dev);
697685

698-
/* ena_com_get_hash_function - Retrieve the hash function and the hash key
699-
* from the device.
686+
/* ena_com_get_hash_function - Retrieve the hash function from the device.
700687
* @ena_dev: ENA communication layer struct
701688
* @func: hash function
702-
* @key: hash key
703689
*
704-
* Retrieve the hash function and the hash key from the device.
690+
* Retrieve the hash function from the device.
705691
*
706692
* @note: If the caller called ena_com_fill_hash_function but didn't flash
707693
* it to the device, the new configuration will be lost.
708694
*
709695
* @return: 0 on Success and negative value otherwise.
710696
*/
711697
int ena_com_get_hash_function(struct ena_com_dev *ena_dev,
712-
enum ena_admin_hash_functions *func,
713-
u8 *key);
698+
enum ena_admin_hash_functions *func);
714699

700+
/* ena_com_get_hash_key - Retrieve the hash key
701+
* @ena_dev: ENA communication layer struct
702+
* @key: hash key
703+
*
704+
* Retrieve the hash key.
705+
*
706+
* @note: If the caller called ena_com_fill_hash_key but didn't flash
707+
* it to the device, the new configuration will be lost.
708+
*
709+
* @return: 0 on Success and negative value otherwise.
710+
*/
711+
int ena_com_get_hash_key(struct ena_com_dev *ena_dev, u8 *key);
715712
/* ena_com_fill_hash_ctrl - Fill RSS hash control
716713
* @ena_dev: ENA communication layer struct.
717714
* @proto: The protocol to configure.

drivers/net/ethernet/amazon/ena/ena_ethtool.c

Lines changed: 40 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ static const struct ena_stats ena_stats_tx_strings[] = {
8383
ENA_STAT_TX_ENTRY(bad_req_id),
8484
ENA_STAT_TX_ENTRY(llq_buffer_copy),
8585
ENA_STAT_TX_ENTRY(missed_tx),
86+
ENA_STAT_TX_ENTRY(unmask_interrupt),
8687
};
8788

8889
static const struct ena_stats ena_stats_rx_strings[] = {
@@ -635,6 +636,32 @@ static u32 ena_get_rxfh_key_size(struct net_device *netdev)
635636
return ENA_HASH_KEY_SIZE;
636637
}
637638

639+
static int ena_indirection_table_set(struct ena_adapter *adapter,
640+
const u32 *indir)
641+
{
642+
struct ena_com_dev *ena_dev = adapter->ena_dev;
643+
int i, rc;
644+
645+
for (i = 0; i < ENA_RX_RSS_TABLE_SIZE; i++) {
646+
rc = ena_com_indirect_table_fill_entry(ena_dev,
647+
i,
648+
ENA_IO_RXQ_IDX(indir[i]));
649+
if (unlikely(rc)) {
650+
netif_err(adapter, drv, adapter->netdev,
651+
"Cannot fill indirect table (index is too large)\n");
652+
return rc;
653+
}
654+
}
655+
656+
rc = ena_com_indirect_table_set(ena_dev);
657+
if (rc) {
658+
netif_err(adapter, drv, adapter->netdev,
659+
"Cannot set indirect table\n");
660+
return rc == -EPERM ? -EOPNOTSUPP : rc;
661+
}
662+
return rc;
663+
}
664+
638665
static int ena_indirection_table_get(struct ena_adapter *adapter, u32 *indir)
639666
{
640667
struct ena_com_dev *ena_dev = adapter->ena_dev;
@@ -672,17 +699,18 @@ static int ena_get_rxfh(struct net_device *netdev, u32 *indir, u8 *key,
672699
/* We call this function in order to check if the device
673700
* supports getting/setting the hash function.
674701
*/
675-
rc = ena_com_get_hash_function(adapter->ena_dev, &ena_func, key);
702+
rc = ena_com_get_hash_function(adapter->ena_dev, &ena_func);
676703
if (rc) {
677-
if (rc == -EOPNOTSUPP) {
678-
key = NULL;
679-
hfunc = NULL;
704+
if (rc == -EOPNOTSUPP)
680705
rc = 0;
681-
}
682706

683707
return rc;
684708
}
685709

710+
rc = ena_com_get_hash_key(adapter->ena_dev, key);
711+
if (rc)
712+
return rc;
713+
686714
switch (ena_func) {
687715
case ENA_ADMIN_TOEPLITZ:
688716
func = ETH_RSS_HASH_TOP;
@@ -699,35 +727,21 @@ static int ena_get_rxfh(struct net_device *netdev, u32 *indir, u8 *key,
699727
if (hfunc)
700728
*hfunc = func;
701729

702-
return rc;
730+
return 0;
703731
}
704732

705733
static int ena_set_rxfh(struct net_device *netdev, const u32 *indir,
706734
const u8 *key, const u8 hfunc)
707735
{
708736
struct ena_adapter *adapter = netdev_priv(netdev);
709737
struct ena_com_dev *ena_dev = adapter->ena_dev;
710-
enum ena_admin_hash_functions func;
711-
int rc, i;
738+
enum ena_admin_hash_functions func = 0;
739+
int rc;
712740

713741
if (indir) {
714-
for (i = 0; i < ENA_RX_RSS_TABLE_SIZE; i++) {
715-
rc = ena_com_indirect_table_fill_entry(ena_dev,
716-
i,
717-
ENA_IO_RXQ_IDX(indir[i]));
718-
if (unlikely(rc)) {
719-
netif_err(adapter, drv, netdev,
720-
"Cannot fill indirect table (index is too large)\n");
721-
return rc;
722-
}
723-
}
724-
725-
rc = ena_com_indirect_table_set(ena_dev);
726-
if (rc) {
727-
netif_err(adapter, drv, netdev,
728-
"Cannot set indirect table\n");
729-
return rc == -EPERM ? -EOPNOTSUPP : rc;
730-
}
742+
rc = ena_indirection_table_set(adapter, indir);
743+
if (rc)
744+
return rc;
731745
}
732746

733747
switch (hfunc) {
@@ -746,7 +760,7 @@ static int ena_set_rxfh(struct net_device *netdev, const u32 *indir,
746760
return -EOPNOTSUPP;
747761
}
748762

749-
if (key) {
763+
if (key || func) {
750764
rc = ena_com_fill_hash_function(ena_dev, func, key,
751765
ENA_HASH_KEY_SIZE,
752766
0xFFFFFFFF);

drivers/net/ethernet/amazon/ena/ena_netdev.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1762,6 +1762,9 @@ static void ena_unmask_interrupt(struct ena_ring *tx_ring,
17621762
tx_ring->smoothed_interval,
17631763
true);
17641764

1765+
u64_stats_update_begin(&tx_ring->syncp);
1766+
tx_ring->tx_stats.unmask_interrupt++;
1767+
u64_stats_update_end(&tx_ring->syncp);
17651768
/* It is a shared MSI-X.
17661769
* Tx and Rx CQ have pointer to it.
17671770
* So we use one of them to reach the intr reg
@@ -3169,6 +3172,7 @@ static void ena_get_stats64(struct net_device *netdev,
31693172
struct ena_ring *rx_ring, *tx_ring;
31703173
unsigned int start;
31713174
u64 rx_drops;
3175+
u64 tx_drops;
31723176
int i;
31733177

31743178
if (!test_bit(ENA_FLAG_DEV_UP, &adapter->flags))
@@ -3203,9 +3207,11 @@ static void ena_get_stats64(struct net_device *netdev,
32033207
do {
32043208
start = u64_stats_fetch_begin_irq(&adapter->syncp);
32053209
rx_drops = adapter->dev_stats.rx_drops;
3210+
tx_drops = adapter->dev_stats.tx_drops;
32063211
} while (u64_stats_fetch_retry_irq(&adapter->syncp, start));
32073212

32083213
stats->rx_dropped = rx_drops;
3214+
stats->tx_dropped = tx_drops;
32093215

32103216
stats->multicast = 0;
32113217
stats->collisions = 0;
@@ -3433,6 +3439,7 @@ static void ena_destroy_device(struct ena_adapter *adapter, bool graceful)
34333439

34343440
ena_com_mmio_reg_read_request_destroy(ena_dev);
34353441

3442+
/* return reset reason to default value */
34363443
adapter->reset_reason = ENA_REGS_RESET_NORMAL;
34373444

34383445
clear_bit(ENA_FLAG_TRIGGER_RESET, &adapter->flags);
@@ -3991,7 +3998,7 @@ static int ena_rss_init_default(struct ena_adapter *adapter)
39913998
}
39923999
}
39934000

3994-
rc = ena_com_fill_hash_function(ena_dev, ENA_ADMIN_CRC32, NULL,
4001+
rc = ena_com_fill_hash_function(ena_dev, ENA_ADMIN_TOEPLITZ, NULL,
39954002
ENA_HASH_KEY_SIZE, 0xFFFFFFFF);
39964003
if (unlikely(rc && (rc != -EOPNOTSUPP))) {
39974004
dev_err(dev, "Cannot fill hash function\n");
@@ -4356,6 +4363,7 @@ static void __ena_shutoff(struct pci_dev *pdev, bool shutdown)
43564363
cancel_work_sync(&adapter->reset_task);
43574364

43584365
rtnl_lock(); /* lock released inside the below if-else block */
4366+
adapter->reset_reason = ENA_REGS_RESET_SHUTDOWN;
43594367
ena_destroy_device(adapter, true);
43604368
if (shutdown) {
43614369
netif_device_detach(netdev);
@@ -4514,14 +4522,17 @@ static void ena_keep_alive_wd(void *adapter_data,
45144522
struct ena_adapter *adapter = (struct ena_adapter *)adapter_data;
45154523
struct ena_admin_aenq_keep_alive_desc *desc;
45164524
u64 rx_drops;
4525+
u64 tx_drops;
45174526

45184527
desc = (struct ena_admin_aenq_keep_alive_desc *)aenq_e;
45194528
adapter->last_keep_alive_jiffies = jiffies;
45204529

45214530
rx_drops = ((u64)desc->rx_drops_high << 32) | desc->rx_drops_low;
4531+
tx_drops = ((u64)desc->tx_drops_high << 32) | desc->tx_drops_low;
45224532

45234533
u64_stats_update_begin(&adapter->syncp);
45244534
adapter->dev_stats.rx_drops = rx_drops;
4535+
adapter->dev_stats.tx_drops = tx_drops;
45254536
u64_stats_update_end(&adapter->syncp);
45264537
}
45274538

0 commit comments

Comments
 (0)