From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=148.163.156.1 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796151837; b=cOHr1bfZI1JGXu9OCgT+BsKBHGYzUkNys8+I/GK52VDaBuSaNu+eFBkNBM1RDns8Ss0Y 8ZjBetUnSLKHN8YlJWTDqJ0bI2+oL4s/ftQX3DcoXLxghAhOBP6FoDk694/RMnw9l5Qkz XzhmHUXduvxIouYpS0iC6h5m2TjZ1tkTS8EkDqgaDrmIZiZwicXsltIrAgiSk+3k1vMCb dyU+ejRvHs9An4QXvr51Fr3VMvh87JaQJlW5ug+vhe0pTWppQgIA2x5F8A11cXnKrtL/k 0BR1RHoM1a7d4W4LKgjkHojgT535ZajagT4snuNvfoBoTyfZHW1RwkE17zoSctB2Byg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796151837; h=DMARC-Filter:Received:DKIM-Signature:Received:Received:Received: Received:Received:Received:Received:From:To:Cc:Subject:Date: Message-Id:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:X-TM-AS-GCONF:X-Proofpoint-Reinject: X-Proofpoint-Spam-Info:X-Proofpoint-ORIG-GUID:X-Proofpoint-GUID: X-Authority-Analysis:X-Proofpoint-Spam-Details-Enc: X-Proofpoint-Virus-Version:X-Proofpoint-Spam-Details; bh=SIurC2FysUg/GQ4lp8GwTW69iKtrPPNOlm93rZaUZ3Y=; b=k7gztuMTjMFP0NUSJdcrkYuPDvCNQQA4C7OlXmytEmliNoYkplJq3pNRMFANd8nn8Kql pEb3zfQLcyv2AsUMYavJARViWMitMuSMT4D4Gh4eaMUL8vrzfh3xTROkM3fPwgQpjx2j9 igATqmgvTwkaVupavEjrFulHPKLA77SAE79RT5mDFe9RJYod0jzw1XJ1cHo4UdgqytZe4 q68Jw8cr98stF+viIYJPf4MBL9Z12BQQ6Z//mhfb4ayR/LM9sWUiMfU2ItfwWKYXTn1qB d9POPUbCSSizy/WYlN1vUyNxZoiAbde6tnSBJzuOHx5ahTnhTreioWWEd5PZtxpD/2A== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=sN0DnvNp; arc=none smtp.remote-ip=148.163.156.1 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DDA2B606A32A for ; Tue, 1 Dec 2026 19:03:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org DDA2B606A32A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=sN0DnvNp Received: from pps.filterd (m0360083.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6B1F6Bmu2275735; Tue, 1 Dec 2026 19:03:33 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=SIurC2FysUg/GQ4lp 8GwTW69iKtrPPNOlm93rZaUZ3Y=; b=sN0DnvNpmtZkZPOxazSwWKCgEZCtHjKXf M7qF0ohIYcXV/EE6Yx/dRgXVP3fAQBRCB+kMd8yFiySxHF31TwEfwZ6Vdf/xMgCP iOYcE4QLU8jZhE4UHq9E9okNdWeEqezKgcYZHHHDD6xy28nebUNmcSluCqyh/fyJ ycUK3Z18ssHEIGbSxuJrttQA6k5mjh3qpBEvMe/9kE8MbIWpsgcvC6yIXE5VMjLh hQqwaFZMWoKGSGr8oWiNUJg5CkJIHao3+mMaKroDWD12cPMXXhMuRjjgmVHlyghd 4pXyxm20vbEe/1Flh5xGWhbqZLkvJzYik/YvH/bjuZGh7jj2sfEWw== Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4j7pf3xdr6-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 01 Dec 2026 19:03:32 +0000 (GMT) Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.18.1.11/8.18.1.11) with ESMTP id 6B1Hf7Jg3003749; Tue, 1 Dec 2026 19:03:31 GMT Received: from smtprelay01.wdc07v.mail.ibm.com ([172.16.1.68]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4ja2uv0bxx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 01 Dec 2026 19:03:31 +0000 (GMT) Received: from smtpav01.wdc07v.mail.ibm.com (smtpav01.wdc07v.mail.ibm.com [10.39.53.228]) by smtprelay01.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 6B1J3TiH59638128 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 1 Dec 2026 19:03:29 GMT Received: from smtpav01.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3888F58065; Tue, 1 Dec 2026 19:03:29 +0000 (GMT) Received: from smtpav01.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E07AC58059; Tue, 1 Dec 2026 19:03:25 +0000 (GMT) Received: from localhost.localdomain (unknown [9.67.162.22]) by smtpav01.wdc07v.mail.ibm.com (Postfix) with ESMTP; Tue, 1 Dec 2026 19:03:25 +0000 (GMT) From: Mingming Cao To: netdev@vger.kernel.org Cc: Mingming Cao , maddy@linux.ibm.com, mpe@ellerman.id.au, npiggin@gmail.com, chleroy@kernel.org, ritesh.list@gmail.com, sshegde@linux.ibm.com, nnac123@linux.ibm.com, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, linuxppc-dev@lists.ozlabs.org, horms@kernel.org, davemarq@linux.ibm.com, haren@linux.ibm.com, ricklind@linux.ibm.com, bjking1@linux.ibm.com, shaik.abdulla1@ibm.com, willemb@google.com Subject: [PATCH net-next v9 13/13] ibmveth: Allow changing the RX queue count Date: Tue, 1 Dec 2026 11:02:16 -0800 Message-Id: <20261201190216.62407-14-mmc@linux.ibm.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) In-Reply-To: <20261201190216.62407-1-mmc@linux.ibm.com> References: <20261201190216.62407-1-mmc@linux.ibm.com> X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-Reinject: loops=2 maxloops=12 X-Proofpoint-Spam-Info: AW1haW4tMjYxMjAxMDA3NCBTYWx0ZWRfXwtjCyHwnGG4C trV3UyZhZtQ49/z6cc681wJpVXTX+RVt8F1M/noAkddv3CVoCgbMG+oR0Ci97LpVXtZ0R9YI7nF g6L9LRALoC0IUcHOAgig6KbE4UaOr4o= X-Proofpoint-ORIG-GUID: 0FWi-qcnR0xa-OFUaCcBlqL4MmFhOZzo X-Proofpoint-GUID: K2qDQ0-RHsPhCm9zm4DTMiNlZgpooHHL X-Authority-Analysis: v=2.4 cv=R6eWitRX c=1 sm=1 tr=0 ts=6b0f1a04 cx=c_pps a=3Bg1Hr4SwmMryq2xdFQyZA==:117 a=3Bg1Hr4SwmMryq2xdFQyZA==:17 a=pUM-KoujPXoA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=iQ6ETzBq9ecOQQE5vZCe:22 a=VnNF1IyMAAAA:8 a=xw2EJvfYqTG1LeZ0bLgA:9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMjAxMDA3NCBTYWx0ZWRfX3kenxD6NoEV+ ehirpXbUM+7rgDtZ9q+0+WmpsTG/2mMgHID0gfXXydx8xr0sMiaclth1FnmZW49N6L0bVUmyBIp kU1v0eHR56e928ZG9J5wzWDzdMRwS0QxxJojsfs/qfbDUp24wbThCEmWQ1n5ii1xXnpg3TDULYF 3oV3GP2IEEnWjkgkZo2yHb6Ejf48HEBWbnRYK7piPxesorpW9AGAke1vkZgBSkDsDvt/U/tOsmg yNBseoZlLuOXHBvv9v7/Jo8TR3dHaq3MUbalh5U2ZxFTeCjnkUSnl8KpoVtyy1BPJiDHKNcpcpt bqEwddr6wMZmVT5JGzipbtRruyDhMEplhbN4FevC48S8uOD9ObTlPVKicmGucLBjUgPyOSXvfry BqzLxkXD2fwjNpm60YOliTzLa1jgpQ5/ghdMyUAfdm8b466PSESwyiCNsxcQrhRKxUN0JyGgLTH ZxdYcBBffw9J/XZYzjA== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.138,FMLib:17.12.100.49 definitions=2026-12-01_03,2026-12-01_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 priorityscore=1501 adultscore=0 spamscore=0 bulkscore=0 phishscore=0 suspectscore=0 malwarescore=0 clxscore=1015 impostorscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2611040001 definitions=main-2612010074 With MQ, ethtool -L still rejects RX count changes, so the count cannot be raised for throughput or lowered to save memory. Accept 1 to 16 RX queues on MQ firmware; without MQ, max_rx stays at the current count. RX queues are registered with PHYP at open, so change the count as change_mtu() does: if the device is up, close it, set the counts and reopen it; if it is down, just set them, so the count can still be lowered if PHYP refuses a queue at open. Traffic stops while the device is closed. A TX-only change keeps the live path. Restore the RX mode after the reopen, since close/open does not run dev_set_rx_mode(). If the reopen fails, restore the old counts and reopen. If either step fails, the device is left closed with IFF_UP still set and whichever counts are in place, so schedule the reset work: it tries one more open and leaves the device down if that fails too. A queue count change is logged with the old and new counts. Signed-off-by: Mingming Cao --- drivers/net/ethernet/ibm/ibmveth.c | 110 +++++++++++++++++++++++++---- 1 file changed, 98 insertions(+), 12 deletions(-) diff --git a/drivers/net/ethernet/ibm/ibmveth.c b/drivers/net/ethernet/ibm/ibmveth.c index 20cb9202b7d3..87ce6bcda472 100644 --- a/drivers/net/ethernet/ibm/ibmveth.c +++ b/drivers/net/ethernet/ibm/ibmveth.c @@ -43,6 +43,7 @@ static irqreturn_t ibmveth_interrupt(int irq, void *dev_instance); static unsigned long ibmveth_get_desired_dma(struct vio_dev *vdev); +static void ibmveth_set_multicast_list(struct net_device *netdev); static struct kobj_type ktype_veth_pool; @@ -1729,7 +1730,8 @@ static int ibmveth_open(struct net_device *netdev) netif_tx_unlock_bh(netdev); adapter->opened = true; - netdev_dbg(netdev, "open complete\n"); + netdev_dbg(netdev, "open complete: %u RX, %u TX queues\n", + adapter->num_rx_queues, netdev->real_num_tx_queues); return 0; @@ -1752,9 +1754,10 @@ static int ibmveth_close(struct net_device *netdev) { struct ibmveth_adapter *adapter = netdev_priv(netdev); - /* change_mtu, pool sysfs, set_csum and set_tso call close() and - * open() directly. If that open() fails, IFF_UP stays set and - * NAPI is disabled; a second close() would hang in napi_disable(). + /* change_mtu, pool sysfs, set_csum, set_tso and set_channels call + * close() and open() directly. If that open() fails, IFF_UP stays + * set and NAPI is disabled; a second close() would hang in + * napi_disable(). */ if (!adapter->opened) return 0; @@ -2144,11 +2147,90 @@ static void ibmveth_get_ethtool_stats(struct net_device *dev, static void ibmveth_get_channels(struct net_device *netdev, struct ethtool_channels *channels) { + struct ibmveth_adapter *adapter = netdev_priv(netdev); + channels->max_tx = ibmveth_real_max_tx_queues(); channels->tx_count = netdev->real_num_tx_queues; - channels->max_rx = netdev->real_num_rx_queues; channels->rx_count = netdev->real_num_rx_queues; + channels->max_rx = adapter->multi_queue ? + IBMVETH_MAX_RX_QUEUES : channels->rx_count; +} + +/* Called with the device closed: open() sizes the RX queues and the TX + * LTBs from these counts. + */ +static int ibmveth_set_queue_counts(struct net_device *netdev, + unsigned int rx, unsigned int tx) +{ + struct ibmveth_adapter *adapter = netdev_priv(netdev); + unsigned int old_rx = adapter->num_rx_queues; + unsigned int old_tx = netdev->real_num_tx_queues; + int rc; + + rc = netif_set_real_num_queues(netdev, tx, rx); + if (!rc) { + adapter->num_rx_queues = rx; + if (old_rx != rx || old_tx != tx) { + if (adapter->multi_queue) + netdev_info(netdev, + "queues %08x: RX %u -> %u, TX %u -> %u\n", + adapter->vdev->unit_address, + old_rx, rx, old_tx, tx); + else if (old_tx != tx) + netdev_info(netdev, + "queues %08x: TX %u -> %u (RX 1)\n", + adapter->vdev->unit_address, + old_tx, tx); + } + } + return rc; +} + +static void ibmveth_restore_rx_mode(struct net_device *netdev) +{ + netif_addr_lock_bh(netdev); + ibmveth_set_multicast_list(netdev); + netif_addr_unlock_bh(netdev); +} + +static int ibmveth_reopen_with_counts(struct net_device *netdev, + unsigned int rx, unsigned int tx) +{ + struct ibmveth_adapter *adapter = netdev_priv(netdev); + unsigned int old_rx = adapter->num_rx_queues; + unsigned int old_tx = netdev->real_num_tx_queues; + int rc, rc2; + + ibmveth_close(netdev); + + rc = ibmveth_set_queue_counts(netdev, rx, tx); + if (!rc) { + rc = ibmveth_open(netdev); + if (!rc) { + ibmveth_restore_rx_mode(netdev); + return 0; + } + if (ibmveth_set_queue_counts(netdev, old_rx, old_tx)) { + netdev_err(netdev, "failed to restore %u RX / %u TX queues\n", + old_rx, old_tx); + goto out_reset; + } + } + + rc2 = ibmveth_open(netdev); + if (!rc2) { + ibmveth_restore_rx_mode(netdev); + return rc; + } + netdev_err(netdev, "reopen with the old queue counts failed: %d\n", + rc2); +out_reset: + /* Closed with IFF_UP set: the reset work closes and reopens once + * more, and dev_open() leaves the device down if that fails. + */ + schedule_work(&adapter->work); + return rc; } static int ibmveth_set_channels(struct net_device *netdev, @@ -2156,16 +2238,20 @@ static int ibmveth_set_channels(struct net_device *netdev, { struct ibmveth_adapter *adapter = netdev_priv(netdev); unsigned int old = netdev->real_num_tx_queues, - goal = channels->tx_count; + goal = channels->tx_count, + rx = channels->rx_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. + /* A TX-only -L resubmits the current rx_count and takes the live + * TX path below. An RX change closes and reopens a running device, + * and applies the TX count in the same window; a closed device + * just takes the new counts. */ - if (channels->rx_count != adapter->num_rx_queues) - return -EOPNOTSUPP; + if (rx != adapter->num_rx_queues) { + if (adapter->opened) + return ibmveth_reopen_with_counts(netdev, rx, goal); + return ibmveth_set_queue_counts(netdev, rx, goal); + } /* If the device is not open (including a failed close/open with * IFF_UP still set) then don't allocate, just set desired -- 2.50.1 (Apple Git-155)