Skip to content

Commit 4bfeadf

Browse files
committed
Merge branch 'sfc-fix-bugs-introduced-by-XDP-patches'
Edward Cree says: ==================== sfc: fix bugs introduced by XDP patches Two fixes for bugs introduced by the XDP support in the sfc driver. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 258a980 + 11a14dc commit 4bfeadf

File tree

3 files changed

+26
-29
lines changed

3 files changed

+26
-29
lines changed

drivers/net/ethernet/sfc/efx.c

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1472,6 +1472,12 @@ static int efx_allocate_msix_channels(struct efx_nic *efx,
14721472
n_xdp_tx = num_possible_cpus();
14731473
n_xdp_ev = DIV_ROUND_UP(n_xdp_tx, EFX_TXQ_TYPES);
14741474

1475+
vec_count = pci_msix_vec_count(efx->pci_dev);
1476+
if (vec_count < 0)
1477+
return vec_count;
1478+
1479+
max_channels = min_t(unsigned int, vec_count, max_channels);
1480+
14751481
/* Check resources.
14761482
* We need a channel per event queue, plus a VI per tx queue.
14771483
* This may be more pessimistic than it needs to be.
@@ -1493,11 +1499,6 @@ static int efx_allocate_msix_channels(struct efx_nic *efx,
14931499
n_xdp_tx, n_xdp_ev);
14941500
}
14951501

1496-
n_channels = min(n_channels, max_channels);
1497-
1498-
vec_count = pci_msix_vec_count(efx->pci_dev);
1499-
if (vec_count < 0)
1500-
return vec_count;
15011502
if (vec_count < n_channels) {
15021503
netif_err(efx, drv, efx->net_dev,
15031504
"WARNING: Insufficient MSI-X vectors available (%d < %u).\n",
@@ -1507,11 +1508,9 @@ static int efx_allocate_msix_channels(struct efx_nic *efx,
15071508
n_channels = vec_count;
15081509
}
15091510

1510-
efx->n_channels = n_channels;
1511+
n_channels = min(n_channels, max_channels);
15111512

1512-
/* Do not create the PTP TX queue(s) if PTP uses the MC directly. */
1513-
if (extra_channels && !efx_ptp_use_mac_tx_timestamps(efx))
1514-
n_channels--;
1513+
efx->n_channels = n_channels;
15151514

15161515
/* Ignore XDP tx channels when creating rx channels. */
15171516
n_channels -= efx->n_xdp_channels;
@@ -1531,11 +1530,10 @@ static int efx_allocate_msix_channels(struct efx_nic *efx,
15311530
efx->n_rx_channels = n_channels;
15321531
}
15331532

1534-
if (efx->n_xdp_channels)
1535-
efx->xdp_channel_offset = efx->tx_channel_offset +
1536-
efx->n_tx_channels;
1537-
else
1538-
efx->xdp_channel_offset = efx->n_channels;
1533+
efx->n_rx_channels = min(efx->n_rx_channels, parallelism);
1534+
efx->n_tx_channels = min(efx->n_tx_channels, parallelism);
1535+
1536+
efx->xdp_channel_offset = n_channels;
15391537

15401538
netif_dbg(efx, drv, efx->net_dev,
15411539
"Allocating %u RX channels\n",
@@ -1550,6 +1548,7 @@ static int efx_allocate_msix_channels(struct efx_nic *efx,
15501548
static int efx_probe_interrupts(struct efx_nic *efx)
15511549
{
15521550
unsigned int extra_channels = 0;
1551+
unsigned int rss_spread;
15531552
unsigned int i, j;
15541553
int rc;
15551554

@@ -1631,8 +1630,7 @@ static int efx_probe_interrupts(struct efx_nic *efx)
16311630
for (i = 0; i < EFX_MAX_EXTRA_CHANNELS; i++) {
16321631
if (!efx->extra_channel_type[i])
16331632
continue;
1634-
if (efx->interrupt_mode != EFX_INT_MODE_MSIX ||
1635-
efx->n_channels <= extra_channels) {
1633+
if (j <= efx->tx_channel_offset + efx->n_tx_channels) {
16361634
efx->extra_channel_type[i]->handle_no_channel(efx);
16371635
} else {
16381636
--j;
@@ -1643,16 +1641,17 @@ static int efx_probe_interrupts(struct efx_nic *efx)
16431641
}
16441642
}
16451643

1644+
rss_spread = efx->n_rx_channels;
16461645
/* RSS might be usable on VFs even if it is disabled on the PF */
16471646
#ifdef CONFIG_SFC_SRIOV
16481647
if (efx->type->sriov_wanted) {
1649-
efx->rss_spread = ((efx->n_rx_channels > 1 ||
1648+
efx->rss_spread = ((rss_spread > 1 ||
16501649
!efx->type->sriov_wanted(efx)) ?
1651-
efx->n_rx_channels : efx_vf_size(efx));
1650+
rss_spread : efx_vf_size(efx));
16521651
return 0;
16531652
}
16541653
#endif
1655-
efx->rss_spread = efx->n_rx_channels;
1654+
efx->rss_spread = rss_spread;
16561655

16571656
return 0;
16581657
}

drivers/net/ethernet/sfc/net_driver.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1533,9 +1533,7 @@ static inline bool efx_channel_is_xdp_tx(struct efx_channel *channel)
15331533

15341534
static inline bool efx_channel_has_tx_queues(struct efx_channel *channel)
15351535
{
1536-
return efx_channel_is_xdp_tx(channel) ||
1537-
(channel->type && channel->type->want_txqs &&
1538-
channel->type->want_txqs(channel));
1536+
return true;
15391537
}
15401538

15411539
static inline struct efx_tx_queue *

drivers/net/ethernet/sfc/rx.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,12 @@ static inline void efx_sync_rx_buffer(struct efx_nic *efx,
9696

9797
void efx_rx_config_page_split(struct efx_nic *efx)
9898
{
99-
efx->rx_page_buf_step = ALIGN(efx->rx_dma_len + efx->rx_ip_align,
99+
efx->rx_page_buf_step = ALIGN(efx->rx_dma_len + efx->rx_ip_align +
100+
XDP_PACKET_HEADROOM,
100101
EFX_RX_BUF_ALIGNMENT);
101102
efx->rx_bufs_per_page = efx->rx_buffer_order ? 1 :
102103
((PAGE_SIZE - sizeof(struct efx_rx_page_state)) /
103-
(efx->rx_page_buf_step + XDP_PACKET_HEADROOM));
104+
efx->rx_page_buf_step);
104105
efx->rx_buffer_truesize = (PAGE_SIZE << efx->rx_buffer_order) /
105106
efx->rx_bufs_per_page;
106107
efx->rx_pages_per_batch = DIV_ROUND_UP(EFX_RX_PREFERRED_BATCH,
@@ -190,14 +191,13 @@ static int efx_init_rx_buffers(struct efx_rx_queue *rx_queue, bool atomic)
190191
page_offset = sizeof(struct efx_rx_page_state);
191192

192193
do {
193-
page_offset += XDP_PACKET_HEADROOM;
194-
dma_addr += XDP_PACKET_HEADROOM;
195-
196194
index = rx_queue->added_count & rx_queue->ptr_mask;
197195
rx_buf = efx_rx_buffer(rx_queue, index);
198-
rx_buf->dma_addr = dma_addr + efx->rx_ip_align;
196+
rx_buf->dma_addr = dma_addr + efx->rx_ip_align +
197+
XDP_PACKET_HEADROOM;
199198
rx_buf->page = page;
200-
rx_buf->page_offset = page_offset + efx->rx_ip_align;
199+
rx_buf->page_offset = page_offset + efx->rx_ip_align +
200+
XDP_PACKET_HEADROOM;
201201
rx_buf->len = efx->rx_dma_len;
202202
rx_buf->flags = 0;
203203
++rx_queue->added_count;

0 commit comments

Comments
 (0)