Skip to content

Commit 49bb536

Browse files
committed
Merge: net/ena: Driver update
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-10/-/merge_requests/1000 JIRA: https://issues.redhat.com/browse/RHEL-94831 Updated Amazon ENA (Elastic Network Adapter) driver to upstream kernel net-next. 1 commit skipped that depends on: https://issues.redhat.com/browse/RHEL-83024 Depends: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-10/-/merge_requests/870 Testing: compiled only (no ENA testing available for LNST) Signed-off-by: Dennis Chen <dechen@redhat.com> Approved-by: Kamal Heib <kheib@redhat.com> Approved-by: José Ignacio Tornos Martínez <jtornosm@redhat.com> Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com> Merged-by: Jan Stancek <jstancek@redhat.com>
2 parents 3578e2d + 5601adb commit 49bb536

File tree

4 files changed

+50
-104
lines changed

4 files changed

+50
-104
lines changed

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

Lines changed: 5 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -763,25 +763,16 @@ static int ena_com_wait_and_process_admin_cq_interrupts(struct ena_comp_ctx *com
763763

764764
if (comp_ctx->status == ENA_CMD_COMPLETED) {
765765
netdev_err(admin_queue->ena_dev->net_device,
766-
"The ena device sent a completion but the driver didn't receive a MSI-X interrupt (cmd %d), autopolling mode is %s\n",
767-
comp_ctx->cmd_opcode, admin_queue->auto_polling ? "ON" : "OFF");
768-
/* Check if fallback to polling is enabled */
769-
if (admin_queue->auto_polling)
770-
admin_queue->polling = true;
766+
"The ena device sent a completion but the driver didn't receive a MSI-X interrupt (cmd %d)\n",
767+
comp_ctx->cmd_opcode);
771768
} else {
772769
netdev_err(admin_queue->ena_dev->net_device,
773770
"The ena device didn't send a completion for the admin cmd %d status %d\n",
774771
comp_ctx->cmd_opcode, comp_ctx->status);
775772
}
776-
/* Check if shifted to polling mode.
777-
* This will happen if there is a completion without an interrupt
778-
* and autopolling mode is enabled. Continuing normal execution in such case
779-
*/
780-
if (!admin_queue->polling) {
781-
admin_queue->running_state = false;
782-
ret = -ETIME;
783-
goto err;
784-
}
773+
admin_queue->running_state = false;
774+
ret = -ETIME;
775+
goto err;
785776
}
786777

787778
ret = ena_com_comp_status_to_errno(admin_queue, comp_ctx->comp_status);
@@ -1650,12 +1641,6 @@ void ena_com_set_admin_polling_mode(struct ena_com_dev *ena_dev, bool polling)
16501641
ena_dev->admin_queue.polling = polling;
16511642
}
16521643

1653-
void ena_com_set_admin_auto_polling_mode(struct ena_com_dev *ena_dev,
1654-
bool polling)
1655-
{
1656-
ena_dev->admin_queue.auto_polling = polling;
1657-
}
1658-
16591644
int ena_com_mmio_reg_read_request_init(struct ena_com_dev *ena_dev)
16601645
{
16611646
struct ena_com_mmio_read *mmio_read = &ena_dev->mmio_read;
@@ -2198,21 +2183,6 @@ int ena_com_get_ena_srd_info(struct ena_com_dev *ena_dev,
21982183
return ret;
21992184
}
22002185

2201-
int ena_com_get_dev_basic_stats(struct ena_com_dev *ena_dev,
2202-
struct ena_admin_basic_stats *stats)
2203-
{
2204-
struct ena_com_stats_ctx ctx;
2205-
int ret;
2206-
2207-
memset(&ctx, 0x0, sizeof(ctx));
2208-
ret = ena_get_dev_stats(ena_dev, &ctx, ENA_ADMIN_GET_STATS_TYPE_BASIC);
2209-
if (likely(ret == 0))
2210-
memcpy(stats, &ctx.get_resp.u.basic_stats,
2211-
sizeof(ctx.get_resp.u.basic_stats));
2212-
2213-
return ret;
2214-
}
2215-
22162186
int ena_com_get_customer_metrics(struct ena_com_dev *ena_dev, char *buffer, u32 len)
22172187
{
22182188
struct ena_admin_aq_get_stats_cmd *get_cmd;
@@ -2289,24 +2259,6 @@ int ena_com_set_dev_mtu(struct ena_com_dev *ena_dev, u32 mtu)
22892259
return ret;
22902260
}
22912261

2292-
int ena_com_get_offload_settings(struct ena_com_dev *ena_dev,
2293-
struct ena_admin_feature_offload_desc *offload)
2294-
{
2295-
int ret;
2296-
struct ena_admin_get_feat_resp resp;
2297-
2298-
ret = ena_com_get_feature(ena_dev, &resp,
2299-
ENA_ADMIN_STATELESS_OFFLOAD_CONFIG, 0);
2300-
if (unlikely(ret)) {
2301-
netdev_err(ena_dev->net_device, "Failed to get offload capabilities %d\n", ret);
2302-
return ret;
2303-
}
2304-
2305-
memcpy(offload, &resp.u.offload, sizeof(resp.u.offload));
2306-
2307-
return 0;
2308-
}
2309-
23102262
int ena_com_set_hash_function(struct ena_com_dev *ena_dev)
23112263
{
23122264
struct ena_com_admin_queue *admin_queue = &ena_dev->admin_queue;

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

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -224,9 +224,6 @@ struct ena_com_admin_queue {
224224
/* Indicate if the admin queue should poll for completion */
225225
bool polling;
226226

227-
/* Define if fallback to polling mode should occur */
228-
bool auto_polling;
229-
230227
u16 curr_cmd_id;
231228

232229
/* Indicate that the ena was initialized and can
@@ -493,17 +490,6 @@ bool ena_com_get_admin_running_state(struct ena_com_dev *ena_dev);
493490
*/
494491
void ena_com_set_admin_polling_mode(struct ena_com_dev *ena_dev, bool polling);
495492

496-
/* ena_com_set_admin_auto_polling_mode - Enable autoswitch to polling mode
497-
* @ena_dev: ENA communication layer struct
498-
* @polling: Enable/Disable polling mode
499-
*
500-
* Set the autopolling mode.
501-
* If autopolling is on:
502-
* In case of missing interrupt when data is available switch to polling.
503-
*/
504-
void ena_com_set_admin_auto_polling_mode(struct ena_com_dev *ena_dev,
505-
bool polling);
506-
507493
/* ena_com_admin_q_comp_intr_handler - admin queue interrupt handler
508494
* @ena_dev: ENA communication layer struct
509495
*
@@ -591,15 +577,6 @@ int ena_com_set_aenq_config(struct ena_com_dev *ena_dev, u32 groups_flag);
591577
int ena_com_get_dev_attr_feat(struct ena_com_dev *ena_dev,
592578
struct ena_com_dev_get_features_ctx *get_feat_ctx);
593579

594-
/* ena_com_get_dev_basic_stats - Get device basic statistics
595-
* @ena_dev: ENA communication layer struct
596-
* @stats: stats return value
597-
*
598-
* @return: 0 on Success and negative value otherwise.
599-
*/
600-
int ena_com_get_dev_basic_stats(struct ena_com_dev *ena_dev,
601-
struct ena_admin_basic_stats *stats);
602-
603580
/* ena_com_get_eni_stats - Get extended network interface statistics
604581
* @ena_dev: ENA communication layer struct
605582
* @stats: stats return value
@@ -635,15 +612,6 @@ int ena_com_get_customer_metrics(struct ena_com_dev *ena_dev, char *buffer, u32
635612
*/
636613
int ena_com_set_dev_mtu(struct ena_com_dev *ena_dev, u32 mtu);
637614

638-
/* ena_com_get_offload_settings - Retrieve the device offloads capabilities
639-
* @ena_dev: ENA communication layer struct
640-
* @offlad: offload return value
641-
*
642-
* @return: 0 on Success and negative value otherwise.
643-
*/
644-
int ena_com_get_offload_settings(struct ena_com_dev *ena_dev,
645-
struct ena_admin_feature_offload_desc *offload);
646-
647615
/* ena_com_rss_init - Init RSS
648616
* @ena_dev: ENA communication layer struct
649617
* @log_size: indirection log size

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

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1129,22 +1129,18 @@ static void ena_dump_stats_ex(struct ena_adapter *adapter, u8 *buf)
11291129
return;
11301130
}
11311131

1132-
strings_buf = devm_kcalloc(&adapter->pdev->dev,
1133-
ETH_GSTRING_LEN, strings_num,
1134-
GFP_ATOMIC);
1132+
strings_buf = kcalloc(strings_num, ETH_GSTRING_LEN, GFP_ATOMIC);
11351133
if (!strings_buf) {
11361134
netif_err(adapter, drv, netdev,
11371135
"Failed to allocate strings_buf\n");
11381136
return;
11391137
}
11401138

1141-
data_buf = devm_kcalloc(&adapter->pdev->dev,
1142-
strings_num, sizeof(u64),
1143-
GFP_ATOMIC);
1139+
data_buf = kcalloc(strings_num, sizeof(u64), GFP_ATOMIC);
11441140
if (!data_buf) {
11451141
netif_err(adapter, drv, netdev,
11461142
"Failed to allocate data buf\n");
1147-
devm_kfree(&adapter->pdev->dev, strings_buf);
1143+
kfree(strings_buf);
11481144
return;
11491145
}
11501146

@@ -1166,8 +1162,8 @@ static void ena_dump_stats_ex(struct ena_adapter *adapter, u8 *buf)
11661162
strings_buf + i * ETH_GSTRING_LEN,
11671163
data_buf[i]);
11681164

1169-
devm_kfree(&adapter->pdev->dev, strings_buf);
1170-
devm_kfree(&adapter->pdev->dev, data_buf);
1165+
kfree(strings_buf);
1166+
kfree(data_buf);
11711167
}
11721168

11731169
void ena_dump_stats_to_buf(struct ena_adapter *adapter, u8 *buf)

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

Lines changed: 40 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ static void ena_tx_timeout(struct net_device *dev, unsigned int txqueue)
7474
if (threshold < time_since_last_napi && napi_scheduled) {
7575
netdev_err(dev,
7676
"napi handler hasn't been called for a long time but is scheduled\n");
77-
reset_reason = ENA_REGS_RESET_SUSPECTED_POLL_STARVATION;
77+
reset_reason = ENA_REGS_RESET_SUSPECTED_POLL_STARVATION;
7878
}
7979
schedule_reset:
8080
/* Change the state of the device to trigger reset
@@ -1677,9 +1677,9 @@ static int ena_request_mgmnt_irq(struct ena_adapter *adapter)
16771677
static int ena_request_io_irq(struct ena_adapter *adapter)
16781678
{
16791679
u32 io_queue_count = adapter->num_io_queues + adapter->xdp_num_queues;
1680+
int rc = 0, i, k, irq_idx;
16801681
unsigned long flags = 0;
16811682
struct ena_irq *irq;
1682-
int rc = 0, i, k;
16831683

16841684
if (!test_bit(ENA_FLAG_MSIX_ENABLED, &adapter->flags)) {
16851685
netif_err(adapter, ifup, adapter->netdev,
@@ -1705,6 +1705,16 @@ static int ena_request_io_irq(struct ena_adapter *adapter)
17051705
irq_set_affinity_hint(irq->vector, &irq->affinity_hint_mask);
17061706
}
17071707

1708+
/* Now that IO IRQs have been successfully allocated map them to the
1709+
* corresponding IO NAPI instance. Note that the mgmnt IRQ does not
1710+
* have a NAPI, so care must be taken to correctly map IRQs to NAPIs.
1711+
*/
1712+
for (i = 0; i < io_queue_count; i++) {
1713+
irq_idx = ENA_IO_IRQ_IDX(i);
1714+
irq = &adapter->irq_tbl[irq_idx];
1715+
netif_napi_set_irq(&adapter->ena_napi[i].napi, irq->vector);
1716+
}
1717+
17081718
return rc;
17091719

17101720
err:
@@ -1797,7 +1807,7 @@ static void ena_init_napi_in_range(struct ena_adapter *adapter,
17971807
if (ENA_IS_XDP_INDEX(adapter, i))
17981808
napi_handler = ena_xdp_io_poll;
17991809

1800-
netif_napi_add(adapter->netdev, &napi->napi, napi_handler);
1810+
netif_napi_add_config(adapter->netdev, &napi->napi, napi_handler, i);
18011811

18021812
if (!ENA_IS_XDP_INDEX(adapter, i))
18031813
napi->rx_ring = rx_ring;
@@ -1811,20 +1821,40 @@ static void ena_napi_disable_in_range(struct ena_adapter *adapter,
18111821
int first_index,
18121822
int count)
18131823
{
1824+
struct napi_struct *napi;
18141825
int i;
18151826

1816-
for (i = first_index; i < first_index + count; i++)
1817-
napi_disable(&adapter->ena_napi[i].napi);
1827+
for (i = first_index; i < first_index + count; i++) {
1828+
napi = &adapter->ena_napi[i].napi;
1829+
if (!ENA_IS_XDP_INDEX(adapter, i)) {
1830+
/* This API is supported for non-XDP queues only */
1831+
netif_queue_set_napi(adapter->netdev, i,
1832+
NETDEV_QUEUE_TYPE_TX, NULL);
1833+
netif_queue_set_napi(adapter->netdev, i,
1834+
NETDEV_QUEUE_TYPE_RX, NULL);
1835+
}
1836+
napi_disable(napi);
1837+
}
18181838
}
18191839

18201840
static void ena_napi_enable_in_range(struct ena_adapter *adapter,
18211841
int first_index,
18221842
int count)
18231843
{
1844+
struct napi_struct *napi;
18241845
int i;
18251846

1826-
for (i = first_index; i < first_index + count; i++)
1827-
napi_enable(&adapter->ena_napi[i].napi);
1847+
for (i = first_index; i < first_index + count; i++) {
1848+
napi = &adapter->ena_napi[i].napi;
1849+
napi_enable(napi);
1850+
if (!ENA_IS_XDP_INDEX(adapter, i)) {
1851+
/* This API is supported for non-XDP queues only */
1852+
netif_queue_set_napi(adapter->netdev, i,
1853+
NETDEV_QUEUE_TYPE_RX, napi);
1854+
netif_queue_set_napi(adapter->netdev, i,
1855+
NETDEV_QUEUE_TYPE_TX, napi);
1856+
}
1857+
}
18281858
}
18291859

18301860
/* Configure the Rx forwarding */
@@ -3245,7 +3275,7 @@ static int ena_destroy_device(struct ena_adapter *adapter, bool graceful)
32453275

32463276
netif_carrier_off(netdev);
32473277

3248-
del_timer_sync(&adapter->timer_service);
3278+
timer_delete_sync(&adapter->timer_service);
32493279

32503280
dev_up = test_bit(ENA_FLAG_DEV_UP, &adapter->flags);
32513281
adapter->dev_up_before_reset = dev_up;
@@ -4065,7 +4095,7 @@ static int ena_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
40654095
ena_free_mgmnt_irq(adapter);
40664096
ena_disable_msix(adapter);
40674097
err_worker_destroy:
4068-
del_timer(&adapter->timer_service);
4098+
timer_delete(&adapter->timer_service);
40694099
err_device_destroy:
40704100
ena_com_delete_host_info(ena_dev);
40714101
ena_com_admin_destroy(ena_dev);
@@ -4111,7 +4141,7 @@ static void __ena_shutoff(struct pci_dev *pdev, bool shutdown)
41114141
/* Make sure timer and reset routine won't be called after
41124142
* freeing device resources.
41134143
*/
4114-
del_timer_sync(&adapter->timer_service);
4144+
timer_delete_sync(&adapter->timer_service);
41154145
cancel_work_sync(&adapter->reset_task);
41164146

41174147
rtnl_lock(); /* lock released inside the below if-else block */

0 commit comments

Comments
 (0)