From nobody Thu Oct 2 21:42:19 2025 Received: from fllvem-ot03.ext.ti.com (fllvem-ot03.ext.ti.com [198.47.19.245]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 63FB931CA65; Thu, 11 Sep 2025 11:42:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.19.245 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757590926; cv=none; b=amIGTXHWBKVopL8+6/Uj6rgLpA6wcrUiJjeEOLFcQOx1DQUfr7s6kLUDFB17wJ1QsAxf2+dkeuxDBrEwHhajKIUwMF7q9ohEI3YZhWnCmoQGLoAeLZaROqAvkfQ1ctOvOlrwunPmcSdNPIW9HqDXvmiJinaFjl9cgcOX5Hv24xQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757590926; c=relaxed/simple; bh=JQQi36eZE14yH3jRBYl6UW9XA0A2eEGQafkfVENT8Ac=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=grYFFn9bvHLQjA6EX4ME36y5+LKTtt8DkHyAPkIax4fGjhz9Gu7VR3+SRRUQD4LV9VSkl6qgwFI4EiEYuz+XKt4oxDyBcLwEJpZ/69gbBH6pXc/drmPAv+tnBIIatxrZlsOjdI0LEREMA2k2R1+oRBPBGl9PnxQS3OBUo1qbgnU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=i5JGUhxZ; arc=none smtp.client-ip=198.47.19.245 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="i5JGUhxZ" Received: from lelvem-sh01.itg.ti.com ([10.180.77.71]) by fllvem-ot03.ext.ti.com (8.15.2/8.15.2) with ESMTP id 58BBaSPF282600; Thu, 11 Sep 2025 06:36:28 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1757590588; bh=MvLpwpR2k8oWPS7J/omjOonARgnQ/9NgXe245RoEZPI=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=i5JGUhxZAtlepksxmLTonKbL9ibKpoQc9n3ck1pQSbI+fWfUeepdUQ9DoYwDw876U 8Ef/8ztmGSbAcSisQMNAXipQL4VMXUKSuBrh633GqFusOsqg8p5gIFxn81e2bFbIcj cbZKFivyWQmOaRmgz8rAvH2F651YJVZk6rUzMvTk= Received: from DFLE105.ent.ti.com (dfle105.ent.ti.com [10.64.6.26]) by lelvem-sh01.itg.ti.com (8.18.1/8.18.1) with ESMTPS id 58BBaSVT464628 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA256 bits=128 verify=FAIL); Thu, 11 Sep 2025 06:36:28 -0500 Received: from DFLE211.ent.ti.com (10.64.6.69) by DFLE105.ent.ti.com (10.64.6.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.55; Thu, 11 Sep 2025 06:36:28 -0500 Received: from fllvem-mr07.itg.ti.com (10.64.41.89) by DFLE211.ent.ti.com (10.64.6.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20 via Frontend Transport; Thu, 11 Sep 2025 06:36:28 -0500 Received: from fllv0122.itg.ti.com (fllv0122.itg.ti.com [10.247.120.72]) by fllvem-mr07.itg.ti.com (8.18.1/8.18.1) with ESMTP id 58BBaSwp1068579; Thu, 11 Sep 2025 06:36:28 -0500 Received: from localhost (danish-tpc.dhcp.ti.com [172.24.231.152]) by fllv0122.itg.ti.com (8.14.7/8.14.7) with ESMTP id 58BBaR4d032081; Thu, 11 Sep 2025 06:36:27 -0500 From: MD Danish Anwar To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Jonathan Corbet , Nishanth Menon , Vignesh Raghavendra , Tero Kristo , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Andrew Lunn , MD Danish Anwar , Mengyuan Lou , Lei Wei , Xin Guo , Michael Ellerman , Fan Gong , Lorenzo Bianconi , Parthiban Veerasooran , Lukas Bulwahn , Geert Uytterhoeven CC: , , , , Subject: [PATCH net-next v4 5/7] net: rpmsg-eth: Add support for multicast filtering Date: Thu, 11 Sep 2025 17:06:10 +0530 Message-ID: <20250911113612.2598643-6-danishanwar@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250911113612.2598643-1-danishanwar@ti.com> References: <20250911113612.2598643-1-danishanwar@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea Content-Type: text/plain; charset="utf-8" Add support for multicast filtering for RPMSG ETH driver. Implement the ndo_set_rx_mode callback as icve_set_rx_mode() API. rx_mode_workqueue is initialized in rpmsg_eth_probe() and queued in rpmsg_eth_set_rx_mode(). Signed-off-by: MD Danish Anwar --- drivers/net/ethernet/rpmsg_eth.c | 63 ++++++++++++++++++++++++++++++++ drivers/net/ethernet/rpmsg_eth.h | 12 ++++++ 2 files changed, 75 insertions(+) diff --git a/drivers/net/ethernet/rpmsg_eth.c b/drivers/net/ethernet/rpmsg_= eth.c index 43196e1d7eeb..cde19d924b89 100644 --- a/drivers/net/ethernet/rpmsg_eth.c +++ b/drivers/net/ethernet/rpmsg_eth.c @@ -80,6 +80,11 @@ static int create_request(struct rpmsg_eth_common *commo= n, ether_addr_copy(msg->req_msg.mac_addr.addr, common->port->ndev->dev_addr); break; + case RPMSG_ETH_REQ_ADD_MC_ADDR: + case RPMSG_ETH_REQ_DEL_MC_ADDR: + ether_addr_copy(msg->req_msg.mac_addr.addr, + common->mcast_addr); + break; case RPMSG_ETH_NOTIFY_PORT_UP: case RPMSG_ETH_NOTIFY_PORT_DOWN: msg->msg_hdr.msg_type =3D RPMSG_ETH_NOTIFY_MSG; @@ -131,6 +136,22 @@ static int rpmsg_eth_create_send_request(struct rpmsg_= eth_common *common, return ret; } =20 +static int rpmsg_eth_add_mc_addr(struct net_device *ndev, const u8 *addr) +{ + struct rpmsg_eth_common *common =3D rpmsg_eth_ndev_to_common(ndev); + + ether_addr_copy(common->mcast_addr, addr); + return rpmsg_eth_create_send_request(common, RPMSG_ETH_REQ_ADD_MC_ADDR, t= rue); +} + +static int rpmsg_eth_del_mc_addr(struct net_device *ndev, const u8 *addr) +{ + struct rpmsg_eth_common *common =3D rpmsg_eth_ndev_to_common(ndev); + + ether_addr_copy(common->mcast_addr, addr); + return rpmsg_eth_create_send_request(common, RPMSG_ETH_REQ_DEL_MC_ADDR, t= rue); +} + static void rpmsg_eth_state_machine(struct work_struct *work) { struct delayed_work *dwork =3D to_delayed_work(work); @@ -213,6 +234,10 @@ static int rpmsg_eth_rpmsg_cb(struct rpmsg_device *rpd= ev, void *data, int len, break; case RPMSG_ETH_RESP_SET_MAC_ADDR: break; + case RPMSG_ETH_RESP_ADD_MC_ADDR: + case RPMSG_ETH_RESP_DEL_MC_ADDR: + complete(&common->sync_msg); + break; } break; case RPMSG_ETH_NOTIFY_MSG: @@ -407,10 +432,15 @@ static int rpmsg_eth_ndo_stop(struct net_device *ndev) =20 netif_carrier_off(port->ndev); =20 + __dev_mc_unsync(ndev, rpmsg_eth_del_mc_addr); + __hw_addr_init(&common->mc_list); + cancel_delayed_work_sync(&common->state_work); timer_delete_sync(&port->rx_timer); napi_disable(&port->rx_napi); =20 + cancel_work_sync(&common->rx_mode_work); + return 0; } =20 @@ -467,10 +497,35 @@ static int rpmsg_eth_set_mac_address(struct net_devic= e *ndev, void *addr) return rpmsg_eth_create_send_request(common, RPMSG_ETH_REQ_SET_MAC_ADDR, = false); } =20 +static void rpmsg_eth_ndo_set_rx_mode_work(struct work_struct *work) +{ + struct rpmsg_eth_common *common; + struct net_device *ndev; + + common =3D container_of(work, struct rpmsg_eth_common, rx_mode_work); + ndev =3D common->port->ndev; + + /* make a mc list copy */ + netif_addr_lock_bh(ndev); + __hw_addr_sync(&common->mc_list, &ndev->mc, ndev->addr_len); + netif_addr_unlock_bh(ndev); + + __hw_addr_sync_dev(&common->mc_list, ndev, rpmsg_eth_add_mc_addr, + rpmsg_eth_del_mc_addr); +} + +static void rpmsg_eth_set_rx_mode(struct net_device *ndev) +{ + struct rpmsg_eth_common *common =3D rpmsg_eth_ndev_to_common(ndev); + + queue_work(common->cmd_wq, &common->rx_mode_work); +} + static const struct net_device_ops rpmsg_eth_netdev_ops =3D { .ndo_open =3D rpmsg_eth_ndo_open, .ndo_stop =3D rpmsg_eth_ndo_stop, .ndo_start_xmit =3D rpmsg_eth_start_xmit, + .ndo_set_rx_mode =3D rpmsg_eth_set_rx_mode, .ndo_set_mac_address =3D rpmsg_eth_set_mac_address, }; =20 @@ -546,6 +601,13 @@ static int rpmsg_eth_probe(struct rpmsg_device *rpdev) INIT_DELAYED_WORK(&common->state_work, rpmsg_eth_state_machine); init_completion(&common->sync_msg); =20 + __hw_addr_init(&common->mc_list); + INIT_WORK(&common->rx_mode_work, rpmsg_eth_ndo_set_rx_mode_work); + common->cmd_wq =3D create_singlethread_workqueue("rpmsg_eth_rx_work"); + if (!common->cmd_wq) { + dev_err(dev, "Failure requesting workqueue\n"); + return -ENOMEM; + } /* Register the network device */ ret =3D rpmsg_eth_init_ndev(common); if (ret) @@ -562,6 +624,7 @@ static void rpmsg_eth_remove(struct rpmsg_device *rpdev) netif_napi_del(&port->rx_napi); timer_delete_sync(&port->rx_timer); unregister_netdev(port->ndev); + destroy_workqueue(common->cmd_wq); =20 dev_dbg(&rpdev->dev, "rpmsg-eth client driver is removed\n"); } diff --git a/drivers/net/ethernet/rpmsg_eth.h b/drivers/net/ethernet/rpmsg_= eth.h index 80fa07be1678..d6112cb9269a 100644 --- a/drivers/net/ethernet/rpmsg_eth.h +++ b/drivers/net/ethernet/rpmsg_eth.h @@ -58,10 +58,14 @@ enum rpmsg_eth_rpmsg_type { /* Request types */ RPMSG_ETH_REQ_SHM_INFO =3D 0, RPMSG_ETH_REQ_SET_MAC_ADDR, + RPMSG_ETH_REQ_ADD_MC_ADDR, + RPMSG_ETH_REQ_DEL_MC_ADDR, =20 /* Response types */ RPMSG_ETH_RESP_SHM_INFO, RPMSG_ETH_RESP_SET_MAC_ADDR, + RPMSG_ETH_RESP_ADD_MC_ADDR, + RPMSG_ETH_RESP_DEL_MC_ADDR, =20 /* Notification types */ RPMSG_ETH_NOTIFY_PORT_UP, @@ -220,6 +224,10 @@ enum rpmsg_eth_state { * @state: Interface state * @state_work: Delayed work for state machine * @sync_msg: Completion for synchronous message + * @rx_mode_work: Work structure for rx mode + * @cmd_wq: Workqueue for commands + * @mc_list: List of multicast addresses + * @mcast_addr: Multicast address filter */ struct rpmsg_eth_common { struct rpmsg_device *rpdev; @@ -237,6 +245,10 @@ struct rpmsg_eth_common { struct mutex state_lock; struct delayed_work state_work; struct completion sync_msg; + struct work_struct rx_mode_work; + struct workqueue_struct *cmd_wq; + struct netdev_hw_addr_list mc_list; + u8 mcast_addr[ETH_ALEN]; }; =20 /** --=20 2.34.1