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=1796151818; b=ue7QXj2viOTzhirxfiHIgLyqZEOnxQ6SGP1GP3NxC7o9eLrAMPAvDDB81saDp5v9sXTX wuS9m8M7+NBiKwOo0i4of4xRpfsn9mgpyKX5SwscZ74O0PwqC9VnKneyn6eUy9Pm2J/X1 Ltx6pqzGPJCFiD8LS0McjLF2HMzDlpnG6zvXD0wF6XYt/pTqbjE5IZLWdv/ypfhpMIdmF B/g5OatiEdhEVBXS+n+bLnrsypL1zrhi55jA5sJmCmXFiUJunf8OnmPaCiTDmsF20FZqY UGB2n5zlwm05eQppfLhxP+0as7qEGuCVNsW9YXk1F9oK6bZ3Mc1dAau5LILC0PEBFUg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796151818; 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-ORIG-GUID:X-Proofpoint-Spam-Details-Enc: X-Proofpoint-GUID:X-Proofpoint-Spam-Info:X-Authority-Analysis: X-Proofpoint-Virus-Version:X-Proofpoint-Spam-Details; bh=KpgO2VxHrudC75MXSmdmc65q/SJj84PqW4DQ/vKfI7w=; b=cdmaYIAKZb/rfY9cvIS1QLdCCOwbMryJZyszrR2YyEhWil2i0zUvjGd/YEIFLDq9qYla tKGuiBpZi2ltYwyvPm/OMez448vployWP2BOCBzLHxMtsARaSfq114r5ukfpvNNI/g73h FVNEuDjziJ8keJzsvZj+sy6S7GyGC+crU1AI6mdeIZpQpdLJWq1576A3l4fPe07JQEl+B OoZCgJgsFq6PsSa3pHlh+BkPY3k04uAZ2soEZDtv/rpb0ssVBf27JnKURvxxchMqK3YSg /wVNmpJTn3Q2mUS5USSbQOBFAzEKR8qVMLFgWZ5dgQ49NaSaNoS6w8kJOqHyLbAAMkA== 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=ebBWc3j2; 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 7B3E5606A31A for ; Tue, 1 Dec 2026 19:03:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 7B3E5606A31A 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=ebBWc3j2 Received: from pps.filterd (m0353729.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6B1F60vE495701; Tue, 1 Dec 2026 19:03:06 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=KpgO2VxHrudC75MXS mdmc65q/SJj84PqW4DQ/vKfI7w=; b=ebBWc3j2iDbaCUmisnGPZcyagb7uf+ewu L6FdGy3bAtsbePulsRO+Z4AGekYZxT2Em+g8dTz8hMWk44bZgCXFw4Jhi33xChHB 01ozQbPmxtk1UNXSuAcBHArpGBADHcShAcl/iAZ/pGMDS3i6NFTnoTtpYs2dyR2P ur+T8YfRrfQtUReRwcsZSA6beKFxQ9P1AivtR7fhRtljuDYDBgYF/BBNkDiVTLqB eqwJFFF6MGdDrYvRKQwZHeGkzeSlnjI+9sTEUe9xY53oQ2/ZE5FSvEsvHePgw8jP GqznCRig3X8SO4aV6kXF5TX8Hmd4phAnRBN2qrN6u+OXxLNcleMog== Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4j7pmt6bcd-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 01 Dec 2026 19:03:05 +0000 (GMT) Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.18.1.11/8.18.1.11) with ESMTP id 6B1ItkwM1019358; Tue, 1 Dec 2026 19:03:04 GMT Received: from smtprelay07.dal12v.mail.ibm.com ([172.16.1.9]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4j89nvjpb9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 01 Dec 2026 19:03:04 +0000 (GMT) Received: from smtpav01.wdc07v.mail.ibm.com (smtpav01.wdc07v.mail.ibm.com [10.39.53.228]) by smtprelay07.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 6B1J32o926411580 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 1 Dec 2026 19:03:03 GMT Received: from smtpav01.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AE04D5804B; Tue, 1 Dec 2026 19:03:02 +0000 (GMT) Received: from smtpav01.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5F9E458059; Tue, 1 Dec 2026 19:02:59 +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:02:59 +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 07/13] ibmveth: Add the MQ RX buffer submit hypercall Date: Tue, 1 Dec 2026 11:02:10 -0800 Message-Id: <20261201190216.62407-8-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-ORIG-GUID: c2qZyB0wzDvmM9XxH7_U1s4K10DSoh4y X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMjAxMDA3NCBTYWx0ZWRfX5JLMCVKlvZcj nLOjF6miMpPvSnAcC/3ClFbfmiYacMrWSW5BzdTsMkDBCxGrqtFwKdHRBJu1YdusNY1zN8GKdTR ptI6kCzsSxUr83rkVdkSfgO8b/HdZ6H8tPPrRJPqJQ3064+cZmrZn/ukx2kwwFIFeGXOX30yauX 2/Rp0QN0MdRDilnl5ss268z8muwId2Lchyuvb1sfzwzKqXzdxxIz/04uCfwoXrzzU8CqTPRt6f7 qrSFRitdbqdngQ5Cob6ikTsHJd8j9O4iJMrRGYET1hIdLuHCQ6WUM47Hi4LADcQeeoEnSetUiP7 aXvMpUh9QG77FTS1oas/zzTuamp3BPUkXHg1SU00lOew2j6YB22YSaaBq0+tG7usw33XlJahDuw p/SslS0ymZdCXDExpaDdA8G5MJC282M5jvfoX8N1pIeHZMDeCxYQSvAmBv3aDLHfG8Oe2KLEqhs hBC4CksoifVTmRY3gQg== X-Proofpoint-GUID: stJ5iTfmqhui6kXy_AYJ-j0ud7AdAi_D X-Proofpoint-Spam-Info: AW1haW4tMjYxMjAxMDA3NCBTYWx0ZWRfX5zxXV5v+mztg geuyvqv1HpNlIxQUQZauX4hXuAqPJH0F415G0cYqQG4Os4l/CZn9+HF+Q5+f+Um+Va8HOIL7GxO XlWUcAhMafT/IeBEmqv9ZFJAA75CivE= X-Authority-Analysis: v=2.4 cv=U9cHnuru c=1 sm=1 tr=0 ts=6b0f19ea cx=c_pps a=5BHTudwdYE3Te8bg5FgnPg==:117 a=5BHTudwdYE3Te8bg5FgnPg==:17 a=pUM-KoujPXoA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=uAbxVGIbfxUO_5tXvNgY:22 a=VnNF1IyMAAAA:8 a=xXrIT8pzxLrnwlQScOQA:9 a=O8hF6Hzn-FEA:10 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 suspectscore=0 adultscore=0 phishscore=0 malwarescore=0 impostorscore=0 lowpriorityscore=0 clxscore=1015 spamscore=0 priorityscore=1501 bulkscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2611040001 definitions=main-2612010074 This is preparation for multi-queue (MQ) RX; nothing sets multi_queue yet, so single-queue behavior does not change. With MQ, every RX queue, queue 0 included, posts buffers with H_ADD_LOGICAL_LAN_BUFFERS_QUEUE against its handle. It packs two buffer addresses per argument, so one call carries up to 12 buffers instead of 8. Add ibmveth_add_logical_lan_buffers(), which picks the hcall for the adapter's mode, and pass the queue index to replenish. IBMVETH_MAX_RX_PER_HCALL becomes 12 and sizes the descriptor array; the legacy hcall keeps its limit of 8 as IBMVETH_MAX_RX_REGULAR, which probe now uses. An unexpected H_FUNCTION (hcall not supported) from the MQ hcall schedules a reset. Unlike the legacy batch hcall, it cannot disappear after Live Partition Migration, since PowerVM blocks migration to a host without MQ. If H_FUNCTION comes back after the reopen, the reset leaves the device down. As with the single queue today, a queue whose refill posts no buffer gets no further interrupt. Signed-off-by: Mingming Cao --- drivers/net/ethernet/ibm/ibmveth.c | 131 ++++++++++++++++++++++++----- drivers/net/ethernet/ibm/ibmveth.h | 41 ++++++++- 2 files changed, 151 insertions(+), 21 deletions(-) diff --git a/drivers/net/ethernet/ibm/ibmveth.c b/drivers/net/ethernet/ibm/ibmveth.c index 1a9499438930..cafbed3d1512 100644 --- a/drivers/net/ethernet/ibm/ibmveth.c +++ b/drivers/net/ethernet/ibm/ibmveth.c @@ -634,11 +634,81 @@ static inline void ibmveth_flush_buffer(void *addr, unsigned long length) asm("dcbf %0,%1,1" :: "b" (addr), "r" (offset)); } +/** + * ibmveth_add_logical_lan_buffers - Add receive buffers to hypervisor + * @adapter: ibmveth adapter structure + * @descs: array of buffer descriptors to add + * @filled: number of valid descriptors in the array + * @buff_size: size of each buffer (multi-queue mode only) + * @queue_index: RX queue index + * + * Return: hypervisor return code + */ +static long ibmveth_add_logical_lan_buffers(struct ibmveth_adapter *adapter, + union ibmveth_buf_desc *descs, + int filled, + unsigned long buff_size, + int queue_index) +{ + struct vio_dev *vdev = adapter->vdev; + long rc; + + /* + * The MQ hcall takes six ioba words (12 packed addresses). The + * legacy hcall takes eight descriptors. The argument lists below + * are written out by hand; keep the defines matched to those lists. + */ + static_assert(IBMVETH_MAX_RX_PER_HCALL == 12); + static_assert(IBMVETH_MAX_RX_REGULAR == 8); + + if (adapter->multi_queue) { + unsigned long buffersznum = (buff_size << 32) | filled; + unsigned long ioba[IBMVETH_MAX_RX_PER_HCALL / 2] = {0}; + unsigned long handle = adapter->queue_handle[queue_index]; + int i; + + /* Even descriptors go in the high 32 bits of an ioba word, + * odd ones in the low 32 bits. + */ + for (i = 0; i < filled && i < IBMVETH_MAX_RX_PER_HCALL; i++) { + int pair_idx = i / 2; + int is_high = (i % 2 == 0); + + if (is_high) + ioba[pair_idx] = (unsigned long) + descs[i].fields.address << 32; + else + ioba[pair_idx] |= descs[i].fields.address; + } + + rc = h_add_logical_lan_buffers_queue(vdev->unit_address, + handle, + buffersznum, + ioba[0], ioba[1], ioba[2], + ioba[3], ioba[4], ioba[5]); + } else if (filled == 1) { + rc = h_add_logical_lan_buffer(vdev->unit_address, + descs[0].desc); + } else { + /* Legacy 8-desc hcall; rx_buffers_per_hcall never exceeds + * IBMVETH_MAX_RX_REGULAR outside multi-queue mode. + */ + rc = h_add_logical_lan_buffers(vdev->unit_address, + descs[0].desc, descs[1].desc, + descs[2].desc, descs[3].desc, + descs[4].desc, descs[5].desc, + descs[6].desc, descs[7].desc); + } + + return rc; +} + /* replenish the buffers for a pool. note that we don't need to * skb_reserve these since they are used for incoming... */ static void ibmveth_replenish_buffer_pool(struct ibmveth_adapter *adapter, - struct ibmveth_buff_pool *pool) + struct ibmveth_buff_pool *pool, + int queue_index) { union ibmveth_buf_desc descs[IBMVETH_MAX_RX_PER_HCALL] = {0}; u32 remaining = pool->size - atomic_read(&pool->available); @@ -724,24 +794,16 @@ static void ibmveth_replenish_buffer_pool(struct ibmveth_adapter *adapter, if (!filled) break; - /* single buffer case*/ - if (filled == 1) - lpar_rc = h_add_logical_lan_buffer(vdev->unit_address, - descs[0].desc); - else - /* Multi-buffer hcall */ - lpar_rc = h_add_logical_lan_buffers(vdev->unit_address, - descs[0].desc, - descs[1].desc, - descs[2].desc, - descs[3].desc, - descs[4].desc, - descs[5].desc, - descs[6].desc, - descs[7].desc); + lpar_rc = ibmveth_add_logical_lan_buffers(adapter, descs, + filled, + pool->buff_size, + queue_index); if (lpar_rc != H_SUCCESS) { dev_warn_ratelimited(dev, - "RX h_add_logical_lan failed: filled=%u, rc=%lu, batch=%u\n", + "RX %s failed: filled=%u, rc=%lu, batch=%u\n", + adapter->multi_queue ? + "h_add_logical_lan_buffers_queue" : + "h_add_logical_lan", filled, lpar_rc, batch); goto hcall_failure; } @@ -782,6 +844,21 @@ hcall_failure: } adapter->replenish_add_buff_failure += filled; + /* PowerVM blocks LPM to a host without MQ support once probe + * has enabled multi-queue mode, so unlike the legacy batch + * hcall below, this hcall cannot disappear across migration. + * Reset on an unexpected H_FUNCTION rather than sit without + * buffers, link up. + */ + if (lpar_rc == H_FUNCTION && adapter->multi_queue) { + dev_err_ratelimited(dev, + "MQ buffer add H_FUNCTION (q=%d, batch=%u), reset\n", + queue_index, batch); + WRITE_ONCE(adapter->mq_hfunc, true); + schedule_work(&adapter->work); + break; + } + /* * If multi rx buffers hcall is no longer supported by FW * e.g. in the case of Live Partition Migration @@ -839,7 +916,8 @@ static void ibmveth_replenish_task(struct ibmveth_adapter *adapter, if (pool->active && (atomic_read(&pool->available) < pool->threshold)) - ibmveth_replenish_buffer_pool(adapter, pool); + ibmveth_replenish_buffer_pool(adapter, pool, + queue_index); } ibmveth_update_rx_no_buffer(adapter); @@ -1543,6 +1621,8 @@ static int ibmveth_close(struct net_device *netdev) netif_tx_disable(netdev); ibmveth_cleanup_rx_interrupts(adapter); + WRITE_ONCE(adapter->mq_hfunc, false); + adapter->mq_hfunc_reopened = false; ibmveth_free_all_queues(adapter); ibmveth_update_rx_no_buffer(adapter); @@ -1578,8 +1658,19 @@ static void ibmveth_reset(struct work_struct *w) rtnl_lock(); if (netif_running(netdev)) { + bool hfunc = READ_ONCE(adapter->mq_hfunc); + bool give_up = hfunc && adapter->mq_hfunc_reopened; + dev_close(netdev); - dev_open(netdev, NULL); + /* Firmware that returns MQ H_FUNCTION again after a reopen + * would do so on every reopen; leave the device down rather + * than close and reopen forever. + */ + if (give_up) + netdev_err(netdev, + "MQ buffer add H_FUNCTION again after reset, leaving device down\n"); + else if (!dev_open(netdev, NULL)) + adapter->mq_hfunc_reopened = hfunc; } rtnl_unlock(); @@ -2846,7 +2937,7 @@ static int ibmveth_probe(struct vio_dev *dev, const struct vio_device_id *id) if (ret == H_SUCCESS && (ret_attr & IBMVETH_ILLAN_RX_MULTI_BUFF_SUPPORT)) { - adapter->rx_buffers_per_hcall = IBMVETH_MAX_RX_PER_HCALL; + 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); diff --git a/drivers/net/ethernet/ibm/ibmveth.h b/drivers/net/ethernet/ibm/ibmveth.h index 398d3a862503..dd89f108e726 100644 --- a/drivers/net/ethernet/ibm/ibmveth.h +++ b/drivers/net/ethernet/ibm/ibmveth.h @@ -100,6 +100,40 @@ h_register_logical_lan_queue(unsigned long unit_address, return rc; } +/** + * h_add_logical_lan_buffers_queue - Add buffers to an RX queue by handle + * @unit_address: Device unit address + * @queue_handle: Queue handle from h_register_logical_lan_queue() or + * h_register_logical_lan_with_handle() (queue 0) + * @buffersznum: Buffer size (upper 32 bits) | count (lower 32 bits) + * @ioba12: Buffer addresses 1 and 2 packed ((addr1 << 32) | addr2) + * @ioba34: Buffer addresses 3 and 4 packed + * @ioba56: Buffer addresses 5 and 6 packed + * @ioba78: Buffer addresses 7 and 8 packed + * @ioba910: Buffer addresses 9 and 10 packed + * @ioba1112: Buffer addresses 11 and 12 packed + * + * Return: hypervisor return code + */ +static inline long h_add_logical_lan_buffers_queue(unsigned long unit_address, + unsigned long queue_handle, + unsigned long buffersznum, + unsigned long ioba12, + unsigned long ioba34, + unsigned long ioba56, + unsigned long ioba78, + unsigned long ioba910, + unsigned long ioba1112) +{ + unsigned long retbuf[PLPAR_HCALL9_BUFSIZE]; + + return plpar_hcall9(H_ADD_LOGICAL_LAN_BUFFERS_QUEUE, + retbuf, unit_address, + queue_handle, buffersznum, + ioba12, ioba34, ioba56, + ioba78, ioba910, ioba1112); +} + /** * h_register_logical_lan_with_handle - Register primary queue and get handle * @unit_address: Device unit address @@ -194,7 +228,8 @@ static inline long h_illan_attributes(unsigned long unit_address, #define IBMVETH_DEFAULT_QUEUES 8U #define IBMVETH_MAX_RX_QUEUES 1U #define IBMVETH_DEFAULT_RX_QUEUES 1U -#define IBMVETH_MAX_RX_PER_HCALL 8U +#define IBMVETH_MAX_RX_REGULAR 8U +#define IBMVETH_MAX_RX_PER_HCALL 12U static int pool_size[] = { 512, 1024 * 2, 1024 * 16, 1024 * 32, 1024 * 64 }; static int pool_count[] = { 256, 512, 256, 256, 256 }; @@ -267,6 +302,10 @@ struct ibmveth_adapter { bool is_active_trunk; /* Set by a successful ibmveth_open(), cleared by ibmveth_close(). */ bool opened; + /* MQ buffer add returned H_FUNCTION; cleared by ibmveth_close(). */ + bool mq_hfunc; + /* ibmveth_reset() reopened after mq_hfunc; cleared by ibmveth_close(). */ + bool mq_hfunc_reopened; unsigned int rx_buffers_per_hcall; u64 fw_ipv6_csum_support; -- 2.50.1 (Apple Git-155)