Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp828711pxb; Tue, 9 Nov 2021 00:28:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJw5D3hTsWHPs/ysqlqRHXA5sI6neH1fH5UqgfRRfZPSh8MCKBm6MrwAdXo8BCEKvSuNPMcL X-Received: by 2002:aa7:c956:: with SMTP id h22mr7673632edt.24.1636446522432; Tue, 09 Nov 2021 00:28:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636446522; cv=none; d=google.com; s=arc-20160816; b=fKst8/Wt7SWUJgQJcDh5h5c3FWWanFfZTINsJ8QJ02jEM0IU5OlNLD983C2nXa/vzi GQzjDdFONTxmIUP3UMVovWsUvdmaru+C3DHm22l0EvTJl5Q0n9aSW73Ptbq62QLr82U2 OMCfbnNo/4R8j78Zgzz9fjYNIb0PCtS6vLv99zxD2uvM9H0xeYy7ZjV9iQQ3Bv/xQRZ5 ikt6T8dynAgmDlSsNWoIveu+JyIUbLONToCs2SaBFspmVUgjHVnLMwu4RE1yNGjL4Mjl YsWpgE9jzkfzPJIDMPYiBM+y2Yp+JA0Tkm6jxvsUIRv0rOXzgxaOmjit5RRBWJ9wsOxr TgRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ISFhTTuupHnKyLMsTaSqEvdNzvBMn+9cCXxI9EmVZBk=; b=TNDKsFdRh5+8dLlm8ltmkDo9NK0HUHBRY2MVpyJQreSo+CXOmQEijLv60j4UFFc9Kb GOa3+JoT4NRGCycWPKRjKiHXDW4v+KyMUugTEKX+6MBL3+xS0wqzUuu38YaXCHofSGjz 3J++m1VsURfWloX6HpCndIoxbH17spe8/NqXutK43x4Zf4aI+DAa8gZStPkyLtL5Kis5 NDsLkdtzd5XdaubTmMCPqQpAXjqk9aU9Q5cjfODejkMsURCezN6w4/qBNA6LAenFl9JO XgUCSquzkIdisjtSS18m4nzNy1xyLBJvFWSYpu18UmkAZ5Anuq8/0wxE56TgK+T6Qyj7 bT2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=AJQ0ueGH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b19si42497206ede.284.2021.11.09.00.28.18; Tue, 09 Nov 2021 00:28:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=AJQ0ueGH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241582AbhKIBEj (ORCPT + 99 others); Mon, 8 Nov 2021 20:04:39 -0500 Received: from mail.kernel.org ([198.145.29.99]:60570 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241663AbhKIBDt (ORCPT ); Mon, 8 Nov 2021 20:03:49 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6024461359; Tue, 9 Nov 2021 01:01:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1636419663; bh=kJabWk3tR5D0fBJ//h2uhG0xDlPR4KZLQpHMsJtcjkY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AJQ0ueGH40xM8QQvyTNszy009d0E8GT45J/GJqL1jtUOLHkxk9xlGI7UB6QFGkUhv 4YoADwt3Vh34OecYjAyVCnW6Wzs8M0bB3pDo7QaiOSzqhAt0l4jj2DQcXK4LNuIGX9 j2mOJ8eD+iieD50fqJ872GT/r+gQ4UdVOtjhM95WBGdya/a/IIYfblk4tMacRed4sG 9pLFUs7ipJdMNIFJLuoYklVAtC8IxPUHu75lodg1Qbk7Perw2P6LjFtXnJUefSU2+d 1l1m9TuqNebyXlFLnnGCeYe8Z1VjS9qVmQ1O94p0R82TqPS1magZwRsxWNNWxCNZ5R iZmL0h4DBcU6A== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Rakesh Babu , Subbaraya Sundeep , Sunil Goutham , "David S . Miller" , Sasha Levin , gakula@marvell.com, hkelam@marvell.com, kuba@kernel.org, netdev@vger.kernel.org Subject: [PATCH AUTOSEL 5.15 037/146] octeontx2-pf: Enable promisc/allmulti match MCAM entries. Date: Mon, 8 Nov 2021 12:43:04 -0500 Message-Id: <20211108174453.1187052-37-sashal@kernel.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211108174453.1187052-1-sashal@kernel.org> References: <20211108174453.1187052-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Rakesh Babu [ Upstream commit ffd2f89ad05cd620d822112a07b0c5669fa9e333 ] Whenever the interface is brought up/down then set_rx_mode function is called by the stack which enables promisc/allmulti MCAM entries. But there are cases when driver brings interface down and then up such as while changing number of channels. In these cases promisc/allmulti MCAM entries are left disabled as set_rx_mode callback is not called. This patch enables these MCAM entries in all such cases. Signed-off-by: Rakesh Babu Signed-off-by: Subbaraya Sundeep Signed-off-by: Sunil Goutham Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- .../ethernet/marvell/octeontx2/nic/otx2_pf.c | 78 ++++++++++--------- 1 file changed, 43 insertions(+), 35 deletions(-) diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c index 53df7fff92c40..53a3e8de1a51e 100644 --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c @@ -1493,6 +1493,44 @@ static void otx2_free_hw_resources(struct otx2_nic *pf) mutex_unlock(&mbox->lock); } +static void otx2_do_set_rx_mode(struct otx2_nic *pf) +{ + struct net_device *netdev = pf->netdev; + struct nix_rx_mode *req; + bool promisc = false; + + if (!(netdev->flags & IFF_UP)) + return; + + if ((netdev->flags & IFF_PROMISC) || + (netdev_uc_count(netdev) > OTX2_MAX_UNICAST_FLOWS)) { + promisc = true; + } + + /* Write unicast address to mcam entries or del from mcam */ + if (!promisc && netdev->priv_flags & IFF_UNICAST_FLT) + __dev_uc_sync(netdev, otx2_add_macfilter, otx2_del_macfilter); + + mutex_lock(&pf->mbox.lock); + req = otx2_mbox_alloc_msg_nix_set_rx_mode(&pf->mbox); + if (!req) { + mutex_unlock(&pf->mbox.lock); + return; + } + + req->mode = NIX_RX_MODE_UCAST; + + if (promisc) + req->mode |= NIX_RX_MODE_PROMISC; + if (netdev->flags & (IFF_ALLMULTI | IFF_MULTICAST)) + req->mode |= NIX_RX_MODE_ALLMULTI; + + req->mode |= NIX_RX_MODE_USE_MCE; + + otx2_sync_mbox_msg(&pf->mbox); + mutex_unlock(&pf->mbox.lock); +} + int otx2_open(struct net_device *netdev) { struct otx2_nic *pf = netdev_priv(netdev); @@ -1646,6 +1684,8 @@ int otx2_open(struct net_device *netdev) if (err) goto err_tx_stop_queues; + otx2_do_set_rx_mode(pf); + return 0; err_tx_stop_queues: @@ -1791,43 +1831,11 @@ static void otx2_set_rx_mode(struct net_device *netdev) queue_work(pf->otx2_wq, &pf->rx_mode_work); } -static void otx2_do_set_rx_mode(struct work_struct *work) +static void otx2_rx_mode_wrk_handler(struct work_struct *work) { struct otx2_nic *pf = container_of(work, struct otx2_nic, rx_mode_work); - struct net_device *netdev = pf->netdev; - struct nix_rx_mode *req; - bool promisc = false; - - if (!(netdev->flags & IFF_UP)) - return; - - if ((netdev->flags & IFF_PROMISC) || - (netdev_uc_count(netdev) > OTX2_MAX_UNICAST_FLOWS)) { - promisc = true; - } - /* Write unicast address to mcam entries or del from mcam */ - if (!promisc && netdev->priv_flags & IFF_UNICAST_FLT) - __dev_uc_sync(netdev, otx2_add_macfilter, otx2_del_macfilter); - - mutex_lock(&pf->mbox.lock); - req = otx2_mbox_alloc_msg_nix_set_rx_mode(&pf->mbox); - if (!req) { - mutex_unlock(&pf->mbox.lock); - return; - } - - req->mode = NIX_RX_MODE_UCAST; - - if (promisc) - req->mode |= NIX_RX_MODE_PROMISC; - if (netdev->flags & (IFF_ALLMULTI | IFF_MULTICAST)) - req->mode |= NIX_RX_MODE_ALLMULTI; - - req->mode |= NIX_RX_MODE_USE_MCE; - - otx2_sync_mbox_msg(&pf->mbox); - mutex_unlock(&pf->mbox.lock); + otx2_do_set_rx_mode(pf); } static int otx2_set_features(struct net_device *netdev, @@ -2358,7 +2366,7 @@ static int otx2_wq_init(struct otx2_nic *pf) if (!pf->otx2_wq) return -ENOMEM; - INIT_WORK(&pf->rx_mode_work, otx2_do_set_rx_mode); + INIT_WORK(&pf->rx_mode_work, otx2_rx_mode_wrk_handler); INIT_WORK(&pf->reset_task, otx2_reset_task); return 0; } -- 2.33.0