Turn on multi-queue (MQ) RX, so an adapter on MQ firmware spreads its receive processing over several queues and CPUs. When firmware sets IBMVETH_ILLAN_RX_MULTI_QUEUE_SUPPORT, probe sets multi_queue and the adapter comes up with netif_get_num_default_rss_queues() RX queues, at most 8; otherwise it stays single-queue. CMO (Cooperative Memory Overcommitment) and MQ firmware do not coexist; probe still keeps MQ off under CMO, because get_desired_dma(), used only under CMO, sizes the entitlement for one queue. PHYP picks the queue for each frame with a hash, so there is no RSS configuration. Raise IBMVETH_MAX_RX_QUEUES to 16, well within the 129 RX queues every MQ adapter can register; RX count changes are rejected until the next patch. MQ posts up to 12 buffers per hcall. Each queue gets its own buffer pools, sized like queue 0's; the poolN sysfs settings apply to every queue. Each queue's RX buffers take about 34 MB, so 8 queues take about 270 MB. Each queue also gets its own NAPI, added with netif_napi_add_config() so it keeps its NAPI ID across reopen and RX count changes, and linked to its queue and IRQ for netdev netlink. Probe adds a NAPI for every RX queue the adapter may use: all 16 when MQ is enabled, otherwise one. This moves the NAPI weight from 16 to the default 64 on every adapter; replenish runs once per poll whatever the budget, so the weight only bounds the frame loop. Queue N's interrupt (N >= 1) is named ibmveth--rxN; queue 0 keeps netdev->name. Received skbs record their RX queue only when there is more than one, so a single-queue adapter that forwards traffic still spreads it over TX queues by flow hash. Probe logs whether the adapter is multi-queue or single-queue, and the reset work logs the adapter it resets. Signed-off-by: Mingming Cao --- drivers/net/ethernet/ibm/ibmveth.c | 140 ++++++++++++++++++++++++++--- drivers/net/ethernet/ibm/ibmveth.h | 5 +- 2 files changed, 132 insertions(+), 13 deletions(-) diff --git a/drivers/net/ethernet/ibm/ibmveth.c b/drivers/net/ethernet/ibm/ibmveth.c index f30d8ba23320..20cb9202b7d3 100644 --- a/drivers/net/ethernet/ibm/ibmveth.c +++ b/drivers/net/ethernet/ibm/ibmveth.c @@ -519,7 +519,31 @@ ibmveth_dispose_subordinate_irq_mappings(struct ibmveth_adapter *adapter) } /** - * ibmveth_setup_rx_interrupts - Register IRQs and enable NAPI + * ibmveth_queue_irq_name - Name for one RX queue's Linux IRQ + * @adapter: ibmveth adapter structure + * @queue_idx: RX queue index + * + * Queue 0 keeps netdev->name, as before multi-queue. Subordinate queues + * use "ibmveth--rx", which survives a rename. + * request_irq() keeps the pointer, so the string lives in the adapter. + * + * Return: the name to pass to request_irq() + */ +static const char *ibmveth_queue_irq_name(struct ibmveth_adapter *adapter, + int queue_idx) +{ + char *name = adapter->queue_irq_name[queue_idx]; + + if (!queue_idx) + return adapter->netdev->name; + + snprintf(name, sizeof(adapter->queue_irq_name[0]), "ibmveth-%x-rx%d", + adapter->vdev->unit_address, queue_idx); + return name; +} + +/** + * ibmveth_setup_rx_interrupts - Register IRQs, enable and link NAPI * @adapter: ibmveth adapter structure * * The queues must already be masked in PHYP: queue 0 before the LAN is @@ -536,7 +560,8 @@ ibmveth_setup_rx_interrupts(struct ibmveth_adapter *adapter) for (i = 0; i < num; i++) { rc = request_irq(adapter->queue_irq[i], ibmveth_interrupt, - 0, netdev->name, &adapter->napi[i]); + 0, ibmveth_queue_irq_name(adapter, i), + &adapter->napi[i]); if (rc) { netdev_err(netdev, "request_irq() failed for irq 0x%x queue %d: %d\n", @@ -545,8 +570,12 @@ ibmveth_setup_rx_interrupts(struct ibmveth_adapter *adapter) } } - for (i = 0; i < num; i++) + for (i = 0; i < num; i++) { + netif_napi_set_irq(&adapter->napi[i], adapter->queue_irq[i]); napi_enable(&adapter->napi[i]); + netif_queue_set_napi(netdev, i, NETDEV_QUEUE_TYPE_RX, + &adapter->napi[i]); + } return 0; @@ -584,8 +613,12 @@ ibmveth_cleanup_rx_interrupts(struct ibmveth_adapter *adapter) synchronize_irq(adapter->queue_irq[i]); } - for (i = 0; i < adapter->num_rx_queues; i++) + for (i = 0; i < adapter->num_rx_queues; i++) { + netif_queue_set_napi(adapter->netdev, i, NETDEV_QUEUE_TYPE_RX, + NULL); + netif_napi_set_irq(&adapter->napi[i], -1); free_irq(adapter->queue_irq[i], &adapter->napi[i]); + } ibmveth_dispose_subordinate_irq_mappings(adapter); } @@ -1131,12 +1164,30 @@ static int ibmveth_alloc_queue_buffer_pools(struct ibmveth_adapter *adapter, * ibmveth_alloc_buffer_pools - Allocate buffer pools for all queues * @adapter: ibmveth adapter structure * + * Copy queue 0's pool metadata onto any further queues, then allocate + * buffer pools for every queue. + * * Return: 0 on success, -ENOMEM on failure */ static int ibmveth_alloc_buffer_pools(struct ibmveth_adapter *adapter) { - int q, rc; + int i, q, rc; + + for (q = 1; q < adapter->num_rx_queues; q++) { + for (i = 0; i < IBMVETH_NUM_BUFF_POOLS; i++) { + struct ibmveth_buff_pool *src = + &adapter->rx_buff_pool[0][i]; + struct ibmveth_buff_pool *dst = + &adapter->rx_buff_pool[q][i]; + + dst->size = src->size; + dst->index = src->index; + dst->buff_size = src->buff_size; + dst->threshold = src->threshold; + dst->active = src->active; + } + } for (q = 0; q < adapter->num_rx_queues; q++) { rc = ibmveth_alloc_queue_buffer_pools(adapter, q); @@ -1753,6 +1804,9 @@ static void ibmveth_reset(struct work_struct *w) bool hfunc = READ_ONCE(adapter->mq_hfunc); bool give_up = hfunc && adapter->mq_hfunc_reopened; + if (net_ratelimit()) + netdev_info(netdev, "resetting %08x (close/open)\n", + adapter->vdev->unit_address); dev_close(netdev); /* Firmware that returns MQ H_FUNCTION again after a reopen * would do so on every reopen; leave the device down rather @@ -2105,6 +2159,14 @@ static int ibmveth_set_channels(struct net_device *netdev, goal = channels->tx_count; int rc, i, alloc_rc = 0; + /* + * RX channel resize is not supported; reject any request that + * changes rx_count. Read-modify-write TX adjustments submit the + * current rx_count and proceed. + */ + if (channels->rx_count != adapter->num_rx_queues) + return -EOPNOTSUPP; + /* If the device is not open (including a failed close/open with * IFF_UP still set) then don't allocate, just set desired * netdev_queue's and return @@ -2631,6 +2693,12 @@ static void ibmveth_poll_deliver_frame(struct napi_struct *napi, ibmveth_rx_csum_helper(skb, adapter); } + /* skb_tx_hash() picks the egress queue from a recorded RX queue + * instead of the flow hash, so only record one when there are + * several. num_rx_queues changes only while the device is closed. + */ + if (adapter->num_rx_queues > 1) + skb_record_rx_queue(skb, queue_index); napi_gro_receive(napi, skb); /* send it up */ IBMVETH_STAT_INC(rxs->packets); @@ -3086,7 +3154,8 @@ static int ibmveth_probe(struct vio_dev *dev, const struct vio_device_id *id) return -EINVAL; } - netdev = alloc_etherdev_mqs(sizeof(struct ibmveth_adapter), IBMVETH_MAX_QUEUES, 1); + netdev = alloc_etherdev_mqs(sizeof(struct ibmveth_adapter), + IBMVETH_MAX_QUEUES, IBMVETH_MAX_RX_QUEUES); if (!netdev) return -ENOMEM; @@ -3099,8 +3168,6 @@ static int ibmveth_probe(struct vio_dev *dev, const struct vio_device_id *id) adapter->mcastFilterSize = be32_to_cpu(*mcastFilterSize_p); ibmveth_init_link_settings(netdev); - netif_napi_add_weight(netdev, &adapter->napi[0], ibmveth_poll, 16); - netdev->irq = dev->irq; netdev->netdev_ops = &ibmveth_netdev_ops; netdev->ethtool_ops = &netdev_ethtool_ops; @@ -3132,11 +3199,36 @@ static int ibmveth_probe(struct vio_dev *dev, const struct vio_device_id *id) netdev->features |= NETIF_F_FRAGLIST; } - adapter->num_rx_queues = IBMVETH_DEFAULT_RX_QUEUES; + /* get_desired_dma() sizes the CMO entitlement for one RX queue. */ + if (ret == H_SUCCESS && + (ret_attr & IBMVETH_ILLAN_RX_MULTI_QUEUE_SUPPORT) && + !firmware_has_feature(FW_FEATURE_CMO)) { + adapter->multi_queue = true; + adapter->num_rx_queues = + min_t(unsigned int, netif_get_num_default_rss_queues(), + IBMVETH_MQ_DEFAULT_RX_QUEUES); + netdev_dbg(netdev, "RX multi queue mode enabled: %u queues\n", + adapter->num_rx_queues); + } else { + adapter->multi_queue = false; + adapter->num_rx_queues = IBMVETH_DEFAULT_RX_QUEUES; + } + + /* MQ may later raise the RX count with ethtool -L, so pre-add every + * possible NAPI with a stable config index. Single-queue adapters + * never grow past one. + */ + for (i = 0; i < (adapter->multi_queue ? IBMVETH_MAX_RX_QUEUES : 1); i++) + netif_napi_add_config(netdev, &adapter->napi[i], + ibmveth_poll, i); if (ret == H_SUCCESS && (ret_attr & IBMVETH_ILLAN_RX_MULTI_BUFF_SUPPORT)) { - adapter->rx_buffers_per_hcall = IBMVETH_MAX_RX_REGULAR; + if (adapter->multi_queue) + adapter->rx_buffers_per_hcall = + IBMVETH_MAX_RX_PER_HCALL; + else + adapter->rx_buffers_per_hcall = IBMVETH_MAX_RX_REGULAR; netdev_dbg(netdev, "RX Multi-buffer hcall supported by FW, batch set to %u\n", adapter->rx_buffers_per_hcall); @@ -3178,10 +3270,34 @@ static int ibmveth_probe(struct vio_dev *dev, const struct vio_device_id *id) rc = netif_set_real_num_tx_queues(netdev, min(num_online_cpus(), IBMVETH_DEFAULT_QUEUES)); if (rc) { - netdev_dbg(netdev, "failed to set number of tx queues rc=%d\n", - rc); + dev_err(&dev->dev, "failed to set number of tx queues rc=%d\n", + rc); goto err_put_pools; } + + /* alloc_etherdev_mqs() set real_num_rx_queues to the maximum. */ + rc = netif_set_real_num_rx_queues(netdev, adapter->num_rx_queues); + if (rc) { + dev_err(&dev->dev, "failed to set number of rx queues rc=%d\n", + rc); + goto err_put_pools; + } + + if (adapter->multi_queue) { + dev_info(&dev->dev, + "Multi-queue LAN %08x: %u RX queues (max %u), %u TX queues\n", + adapter->vdev->unit_address, adapter->num_rx_queues, + IBMVETH_MAX_RX_QUEUES, netdev->real_num_tx_queues); + } else { + dev_info(&dev->dev, + "Single-queue LAN %08x: %u TX queues (h_illan rc=%ld, FW MQ=%d, CMO=%d)\n", + adapter->vdev->unit_address, + netdev->real_num_tx_queues, ret, + (ret == H_SUCCESS && + (ret_attr & IBMVETH_ILLAN_RX_MULTI_QUEUE_SUPPORT)) ? 1 : 0, + firmware_has_feature(FW_FEATURE_CMO) ? 1 : 0); + } + adapter->tx_ltb_size = PAGE_ALIGN(IBMVETH_MAX_TX_BUF_SIZE); for (i = 0; i < IBMVETH_MAX_QUEUES; i++) adapter->tx_ltb_ptr[i] = NULL; diff --git a/drivers/net/ethernet/ibm/ibmveth.h b/drivers/net/ethernet/ibm/ibmveth.h index 588209144de7..be6207fba9e3 100644 --- a/drivers/net/ethernet/ibm/ibmveth.h +++ b/drivers/net/ethernet/ibm/ibmveth.h @@ -30,6 +30,7 @@ #define IbmVethMcastRemoveFilter 0x2UL #define IbmVethMcastClearFilterTable 0x3UL +#define IBMVETH_ILLAN_RX_MULTI_QUEUE_SUPPORT 0x0000000000080000UL #define IBMVETH_ILLAN_RX_MULTI_BUFF_SUPPORT 0x0000000000040000UL #define IBMVETH_ILLAN_LRG_SR_ENABLED 0x0000000000010000UL #define IBMVETH_ILLAN_LRG_SND_SUPPORT 0x0000000000008000UL @@ -226,8 +227,9 @@ static inline long h_illan_attributes(unsigned long unit_address, #define IBMVETH_MAX_TX_BUF_SIZE (1024 * 64) #define IBMVETH_MAX_QUEUES 16U #define IBMVETH_DEFAULT_QUEUES 8U -#define IBMVETH_MAX_RX_QUEUES 1U +#define IBMVETH_MAX_RX_QUEUES 16U #define IBMVETH_DEFAULT_RX_QUEUES 1U +#define IBMVETH_MQ_DEFAULT_RX_QUEUES 8U #define IBMVETH_MAX_RX_REGULAR 8U #define IBMVETH_MAX_RX_PER_HCALL 12U @@ -320,6 +322,7 @@ struct ibmveth_adapter { * queue 0 uses h_vio_signal(), so entry 0 is never read. */ unsigned long queue_hwirq[IBMVETH_MAX_RX_QUEUES]; + char queue_irq_name[IBMVETH_MAX_RX_QUEUES][32]; bool multi_queue; unsigned int num_rx_queues; int rx_csum; -- 2.50.1 (Apple Git-155)