History

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. ====================

David S. Miller committed 6 years ago

Commit 4bfeadf2 parents 258a980 11a14dc3 files · +26 −29Browse files

Unified · Split

3 files
  1. drivers/net/ethernet/sfc/efx.c +18 −19
  2. drivers/net/ethernet/sfc/net_driver.h +1 −3
  3. drivers/net/ethernet/sfc/rx.c +7 −7
drivers/net/ethernet/sfc/efx.c+18−19
@@ -1472,6 +1472,12 @@ static int efx_allocate_msix_channels(struct efx_nic *efx, · 1471 unmodified lines
1472 n_xdp_tx = num_possible_cpus();1472 n_xdp_tx = num_possible_cpus();
1473 n_xdp_ev = DIV_ROUND_UP(n_xdp_tx, EFX_TXQ_TYPES);1473 n_xdp_ev = DIV_ROUND_UP(n_xdp_tx, EFX_TXQ_TYPES);
1474 1474
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
1475 /* Check resources.1481 /* Check resources.
1476 * We need a channel per event queue, plus a VI per tx queue.1482 * We need a channel per event queue, plus a VI per tx queue.
1477 * This may be more pessimistic than it needs to be.1483 * This may be more pessimistic than it needs to be.
@@ -1493,11 +1499,6 @@ static int efx_allocate_msix_channels(struct efx_nic *efx, · 15 unmodified lines
1493 n_xdp_tx, n_xdp_ev);1499 n_xdp_tx, n_xdp_ev);
1494 }1500 }
1495 1501
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;
1501 if (vec_count < n_channels) {1502 if (vec_count < n_channels) {
1502 netif_err(efx, drv, efx->net_dev,1503 netif_err(efx, drv, efx->net_dev,
1503 "WARNING: Insufficient MSI-X vectors available (%d < %u).\n",1504 "WARNING: Insufficient MSI-X vectors available (%d < %u).\n",
@@ -1507,11 +1508,9 @@ static int efx_allocate_msix_channels(struct efx_nic *efx, · 3 unmodified lines
1507 n_channels = vec_count;1508 n_channels = vec_count;
1508 }1509 }
1509 1510
1510 efx->n_channels = n_channels;1511 n_channels = min(n_channels, max_channels);
1511 1512
1512 /* Do not create the PTP TX queue(s) if PTP uses the MC directly. */1513 efx->n_channels = n_channels;
1513 if (extra_channels && !efx_ptp_use_mac_tx_timestamps(efx))
1514 n_channels--;
1515 1514
1516 /* Ignore XDP tx channels when creating rx channels. */1515 /* Ignore XDP tx channels when creating rx channels. */
1517 n_channels -= efx->n_xdp_channels;1516 n_channels -= efx->n_xdp_channels;
@@ -1531,11 +1530,10 @@ static int efx_allocate_msix_channels(struct efx_nic *efx, · 13 unmodified lines
1531 efx->n_rx_channels = n_channels;1530 efx->n_rx_channels = n_channels;
1532 }1531 }
1533 1532
1534 if (efx->n_xdp_channels)1533 efx->n_rx_channels = min(efx->n_rx_channels, parallelism);
1535 efx->xdp_channel_offset = efx->tx_channel_offset +1534 efx->n_tx_channels = min(efx->n_tx_channels, parallelism);
1536 efx->n_tx_channels;1535
1537 else1536 efx->xdp_channel_offset = n_channels;
1538 efx->xdp_channel_offset = efx->n_channels;
1539 1537
1540 netif_dbg(efx, drv, efx->net_dev,1538 netif_dbg(efx, drv, efx->net_dev,
1541 "Allocating %u RX channels\n",1539 "Allocating %u RX channels\n",
@@ -1550,6 +1548,7 @@ static int efx_allocate_msix_channels(struct efx_nic *efx, · 8 unmodified lines
1550static int efx_probe_interrupts(struct efx_nic *efx)1548static int efx_probe_interrupts(struct efx_nic *efx)
1551{1549{
1552 unsigned int extra_channels = 0;1550 unsigned int extra_channels = 0;
1551 unsigned int rss_spread;
1553 unsigned int i, j;1552 unsigned int i, j;
1554 int rc;1553 int rc;
1555 1554
@@ -1631,8 +1630,7 @@ static int efx_probe_interrupts(struct efx_nic *efx) · 75 unmodified lines
1631 for (i = 0; i < EFX_MAX_EXTRA_CHANNELS; i++) {1630 for (i = 0; i < EFX_MAX_EXTRA_CHANNELS; i++) {
1632 if (!efx->extra_channel_type[i])1631 if (!efx->extra_channel_type[i])
1633 continue;1632 continue;
1634 if (efx->interrupt_mode != EFX_INT_MODE_MSIX ||1633 if (j <= efx->tx_channel_offset + efx->n_tx_channels) {
1635 efx->n_channels <= extra_channels) {
1636 efx->extra_channel_type[i]->handle_no_channel(efx);1634 efx->extra_channel_type[i]->handle_no_channel(efx);
1637 } else {1635 } else {
1638 --j;1636 --j;
@@ -1643,16 +1641,17 @@ static int efx_probe_interrupts(struct efx_nic *efx) · 4 unmodified lines
1643 }1641 }
1644 }1642 }
1645 1643
1644 rss_spread = efx->n_rx_channels;
1646 /* RSS might be usable on VFs even if it is disabled on the PF */1645 /* RSS might be usable on VFs even if it is disabled on the PF */
1647#ifdef CONFIG_SFC_SRIOV1646#ifdef CONFIG_SFC_SRIOV
1648 if (efx->type->sriov_wanted) {1647 if (efx->type->sriov_wanted) {
1649 efx->rss_spread = ((efx->n_rx_channels > 1 ||1648 efx->rss_spread = ((rss_spread > 1 ||
1650 !efx->type->sriov_wanted(efx)) ?1649 !efx->type->sriov_wanted(efx)) ?
1651 efx->n_rx_channels : efx_vf_size(efx));1650 rss_spread : efx_vf_size(efx));
1652 return 0;1651 return 0;
1653 }1652 }
1654#endif1653#endif
1655 efx->rss_spread = efx->n_rx_channels;1654 efx->rss_spread = rss_spread;
1656 1655
1657 return 0;1656 return 0;
1658}1657}
drivers/net/ethernet/sfc/net_driver.h+1−3
@@ -1533,9 +1533,7 @@ static inline bool efx_channel_is_xdp_tx(struct efx_channel *channel) · 1532 unmodified lines
1533 1533
1534static inline bool efx_channel_has_tx_queues(struct efx_channel *channel)1534static inline bool efx_channel_has_tx_queues(struct efx_channel *channel)
1535{1535{
1536 return efx_channel_is_xdp_tx(channel) ||1536 return true;
1537 (channel->type && channel->type->want_txqs &&
1538 channel->type->want_txqs(channel));
1539}1537}
1540 1538
1541static inline struct efx_tx_queue *1539static inline struct efx_tx_queue *
drivers/net/ethernet/sfc/rx.c+7−7
@@ -96,11 +96,12 @@ static inline void efx_sync_rx_buffer(struct efx_nic *efx, · 95 unmodified lines
96 96
97void efx_rx_config_page_split(struct efx_nic *efx)97void efx_rx_config_page_split(struct efx_nic *efx)
98{98{
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,
100 EFX_RX_BUF_ALIGNMENT);101 EFX_RX_BUF_ALIGNMENT);
101 efx->rx_bufs_per_page = efx->rx_buffer_order ? 1 :102 efx->rx_bufs_per_page = efx->rx_buffer_order ? 1 :
102 ((PAGE_SIZE - sizeof(struct efx_rx_page_state)) /103 ((PAGE_SIZE - sizeof(struct efx_rx_page_state)) /
103 (efx->rx_page_buf_step + XDP_PACKET_HEADROOM));104 efx->rx_page_buf_step);
104 efx->rx_buffer_truesize = (PAGE_SIZE << efx->rx_buffer_order) /105 efx->rx_buffer_truesize = (PAGE_SIZE << efx->rx_buffer_order) /
105 efx->rx_bufs_per_page;106 efx->rx_bufs_per_page;
106 efx->rx_pages_per_batch = DIV_ROUND_UP(EFX_RX_PREFERRED_BATCH,107 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) · 83 unmodified lines
190 page_offset = sizeof(struct efx_rx_page_state);191 page_offset = sizeof(struct efx_rx_page_state);
191 192
192 do {193 do {
193 page_offset += XDP_PACKET_HEADROOM;
194 dma_addr += XDP_PACKET_HEADROOM;
195
196 index = rx_queue->added_count & rx_queue->ptr_mask;194 index = rx_queue->added_count & rx_queue->ptr_mask;
197 rx_buf = efx_rx_buffer(rx_queue, index);195 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;
199 rx_buf->page = page;198 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;
201 rx_buf->len = efx->rx_dma_len;201 rx_buf->len = efx->rx_dma_len;
202 rx_buf->flags = 0;202 rx_buf->flags = 0;
203 ++rx_queue->added_count;203 ++rx_queue->added_count;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t