From patchwork Wed Jan 5 10:32:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Gouin X-Patchwork-Id: 105655 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 4F928A034D; Thu, 6 Jan 2022 09:41:41 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8D5B041140; Thu, 6 Jan 2022 09:41:36 +0100 (CET) Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) by mails.dpdk.org (Postfix) with ESMTP id 766E54014F for ; Wed, 5 Jan 2022 11:32:25 +0100 (CET) Received: by mail-wr1-f45.google.com with SMTP id e5so81999930wrc.5 for ; Wed, 05 Jan 2022 02:32:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind.com; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=iluSdXNW98q+cxkbh2Si9orG5tXPP3YXLwJL/94DhMc=; b=SMTpNbO2RYXi4JTzH5zW93KctKDy8VGCEop9Vuzyshvzf1Lodym0CHq8yXAbQpMUWg kV7SMJs/w3yfJZ2XfnpZM9LTMosNaTOdfw+HkdjzW2IgBNDLCnCjGigBGYFzukK0EJPv IGVHW0Al5a4CAICoU+vRuNWdJZWHVO+Isblxx2X2vAYYauMMVczP8Mfbppwnq4aBCyKL /H8poGbakpxo1RJ2szQWpOOXL/GIy0IAyQTfqVIYG2Ocb0/omVcTmcIIzQnqLS7NchLV NeCzV/vYtmN9+UHA98g0tSDN7Dtp1G80vQRVXDpBNw6p6s8pHL0MmkVJjDCJYzJg3ch5 jvxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=iluSdXNW98q+cxkbh2Si9orG5tXPP3YXLwJL/94DhMc=; b=KwFgIEc1os0q0OBCi4uCOncya5vuhwysSqsk8f3cvEYqdCcUnmBBfGhCjbCFuPJIqj pX8vvQvewnSaeIjKWzKmv0cvVX/3raR2mwCrkVXHy4Cz0z/jys4L0BwJXOfHQvWWR5r+ 4GQaPbSP3oLxfsAniMeLnieEIV0lfeS6T7PlHxkTWulyUztCFNvCEjhIHua+6/QWiS4P G5/f31Pwh0bY0pGMv95xxTLl6DmQERdTiFIgxsNXDNsWi/5H4w9gotF52FQW5JLJyjYh /A7Ah2Mbkkj/wlERqDwGGhqe7MjVs92i9RDn/PpKUhsUZVFfuJmB9zLnYpJk9qgyayKD aKbg== X-Gm-Message-State: AOAM532/el+OKRFsfiUYD6kTg+Qi2mRiwNddOafruhM93ZZy7kY9cDOt 7DgIfAJNtInWPiTFw7NYYYFth1Vk3eudfQy3 X-Google-Smtp-Source: ABdhPJyAgbmAU3QWbNttUkJR3iKaxAdM82BvUPVzF1MvmLeL7AcTOEXcBjVHHrxDt3OOjxJY5G6zbA== X-Received: by 2002:a5d:46d0:: with SMTP id g16mr48266230wrs.624.1641378745164; Wed, 05 Jan 2022 02:32:25 -0800 (PST) Received: from dokken.dev.6wind.com ([185.13.181.2]) by smtp.gmail.com with ESMTPSA id j11sm1777677wmq.23.2022.01.05.02.32.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jan 2022 02:32:24 -0800 (PST) From: Maxime Gouin To: dev@dpdk.org Cc: Maxime Gouin , Heinrich Kuhn , Alejandro Lucero , Olivier Matz Subject: [PATCH 1/2] net/nfp: remove duplicated check when setting MAC address Date: Wed, 5 Jan 2022 11:32:02 +0100 Message-Id: <20220105103203.7166-1-maxime.gouin@6wind.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-Mailman-Approved-At: Thu, 06 Jan 2022 09:41:34 +0100 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org reported by code analysis tool C++test (version 10.4): > /build/dpdk-20.11/drivers/net/nfp/nfp_net.c > 546 Conditions "(hw->ctrl &NFP_NET_CFG_CTRL_ENABLE) && !! (hw->cap &NFP_NET_CFG_C" is always evaluated to false > 547 Condition "! (hw->cap &NFP_NET_CFG_C" is always evaluated to false The previous "if" checks exactly the same condition. Removal of duplicate code. Fixes: 2fe669f4bcd2 ("net/nfp: support MAC address change") Signed-off-by: Maxime Gouin Reviewed-by: Olivier Matz Acked-by: Kevin Traynor --- drivers/net/nfp/nfp_common.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/net/nfp/nfp_common.c b/drivers/net/nfp/nfp_common.c index f8978e803a0f..b26770dbfbe4 100644 --- a/drivers/net/nfp/nfp_common.c +++ b/drivers/net/nfp/nfp_common.c @@ -280,10 +280,6 @@ nfp_set_mac_addr(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr) return -EBUSY; } - if ((hw->ctrl & NFP_NET_CFG_CTRL_ENABLE) && - !(hw->cap & NFP_NET_CFG_CTRL_LIVE_ADDR)) - return -EBUSY; - /* Writing new MAC to the specific port BAR address */ nfp_net_write_mac(hw, (uint8_t *)mac_addr); From patchwork Wed Jan 5 10:32:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Gouin X-Patchwork-Id: 105656 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 5BD04A034D; Thu, 6 Jan 2022 09:41:46 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7BC2341150; Thu, 6 Jan 2022 09:41:37 +0100 (CET) Received: from mail-wr1-f46.google.com (mail-wr1-f46.google.com [209.85.221.46]) by mails.dpdk.org (Postfix) with ESMTP id 0A15B4014F for ; Wed, 5 Jan 2022 11:32:36 +0100 (CET) Received: by mail-wr1-f46.google.com with SMTP id s1so82021338wra.6 for ; Wed, 05 Jan 2022 02:32:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=07V1+tb9xarimfxfPETik1EDR+kunkjAgLwHY3nxlBg=; b=WY3dpwhZ/j86FeRVW6N8eM/ufygxmchpNjJ8zBfqAFgk4A4yn2BfYmX3RHNDBJk80p ngY2oEFLGB6BSuJA8ytekhiPemgPGknzpZEyKqNTi2Klg4nL9golofGZmkHb9bT3fDyB j3DMnF6OetnOB+Fq7Q2aGY0RcdmwTclhOyjuAaiqA4Uds8OBveEYSrQV6Iu+3EWYSyW9 KFnfRHnuUTGnYi+bItIHTXbOvDsXppqL8iqaUWee3sEARjRoC/eoAIRsLFQ63zkOt/h5 kuL5B9WQ4CWhSJTFhkzoB37klVeURUqZN9R1FMtCjSXOHvsDqxQqUCpJGfMJvlq0lfQd 5ksg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=07V1+tb9xarimfxfPETik1EDR+kunkjAgLwHY3nxlBg=; b=KOTUc8/BwYIycaytaE0rwpnJ25K9a+7/tcvfPwXUHTZGxuoOAwBoliYx1XNrfUQtfq aHGJ/JI9OslMP96qrdTzwNzvzcRr/Cq6M52HRCC5rYV/X2wK90lPjHSi4WOaE0DENYYe 1wmmBzDO9Hvws5QYqTI9m0JYaOrdAJyJgJMcwNacyXlGpucqn63Jo+2ndfG5VoEMPXAw W1VaMDIP+9gGmA+BU2g3omYWxdtEoatbBTIkBqXfcEFa+8Fgc88F4/Uv0o5JImyGq04M QK9bqMNiKMto7wzXv9+20TLA0PwXhHet0tNd7mqZT6fUldBml2yG02if7bLSAGawuPnK 6Akw== X-Gm-Message-State: AOAM533uulfOa613mGOoY+8aj2/f/lXZlX5ZiTav3GYqW++4NgKNE4tr g4tUaQa8ShJJ1WXFe+Q6pIUHIxgfHmUKRyID X-Google-Smtp-Source: ABdhPJzRDmRfn8MHaBvh1JLtN5x/2QxxwfWPnoq/jBVapZnf1jxo8vXkH27ATuVjTdIrIxuckIznPw== X-Received: by 2002:a05:6000:1845:: with SMTP id c5mr45688516wri.420.1641378755818; Wed, 05 Jan 2022 02:32:35 -0800 (PST) Received: from dokken.dev.6wind.com ([185.13.181.2]) by smtp.gmail.com with ESMTPSA id j11sm1777677wmq.23.2022.01.05.02.32.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jan 2022 02:32:35 -0800 (PST) From: Maxime Gouin To: dev@dpdk.org Cc: Maxime Gouin , Heinrich Kuhn , Alejandro Lucero , Olivier Matz Subject: [PATCH 2/2] net/nfp: remove useless range checks Date: Wed, 5 Jan 2022 11:32:03 +0100 Message-Id: <20220105103203.7166-2-maxime.gouin@6wind.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220105103203.7166-1-maxime.gouin@6wind.com> References: <20220105103203.7166-1-maxime.gouin@6wind.com> MIME-Version: 1.0 X-Mailman-Approved-At: Thu, 06 Jan 2022 09:41:35 +0100 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org reported by code analysis tool C++test (version 10.4): > /build/dpdk-20.11/drivers/net/nfp/nfpcore/nfp_target.h > 375 Condition "island < 1" is always evaluated to false > 415 Condition "island < 1" is always evaluated to false > 547 Condition "target < 0" is always evaluated to false All of these conditions have the same error. They call NFP_CPP_ID_ISLAND_of or NFP_CPP_ID_TARGET_of which return a uint8_t and put the result in "island" or "target" which are integers. These variables can only contain values between 0 and 255. Fixes: c7e9729da6b5 ("net/nfp: support CPP") Signed-off-by: Maxime Gouin Reviewed-by: Olivier Matz Acked-by: Kevin Traynor Reviewed-by: Ferruh Yigit --- drivers/net/nfp/nfpcore/nfp_target.h | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/net/nfp/nfpcore/nfp_target.h b/drivers/net/nfp/nfpcore/nfp_target.h index 2884a0034f44..e8dcc9ad1eda 100644 --- a/drivers/net/nfp/nfpcore/nfp_target.h +++ b/drivers/net/nfp/nfpcore/nfp_target.h @@ -37,7 +37,7 @@ pushpull_width(int pp) static inline int target_rw(uint32_t cpp_id, int pp, int start, int len) { - int island = NFP_CPP_ID_ISLAND_of(cpp_id); + uint8_t island = NFP_CPP_ID_ISLAND_of(cpp_id); if (island && (island < start || island > (start + len))) return NFP_ERRNO(EINVAL); @@ -117,7 +117,7 @@ nfp6000_nbi_ppc(uint32_t cpp_id) static inline int nfp6000_nbi(uint32_t cpp_id, uint64_t address) { - int island = NFP_CPP_ID_ISLAND_of(cpp_id); + uint8_t island = NFP_CPP_ID_ISLAND_of(cpp_id); uint64_t rel_addr = address & 0x3fFFFF; if (island && (island < 8 || island > 9)) @@ -281,7 +281,7 @@ static inline int nfp6000_mu(uint32_t cpp_id, uint64_t address) { int pp; - int island = NFP_CPP_ID_ISLAND_of(cpp_id); + uint8_t island = NFP_CPP_ID_ISLAND_of(cpp_id); if (island == 0) { if (address < 0x2000000000ULL) @@ -316,7 +316,7 @@ nfp6000_mu(uint32_t cpp_id, uint64_t address) static inline int nfp6000_ila(uint32_t cpp_id) { - int island = NFP_CPP_ID_ISLAND_of(cpp_id); + uint8_t island = NFP_CPP_ID_ISLAND_of(cpp_id); if (island && (island < 48 || island > 51)) return NFP_ERRNO(EINVAL); @@ -336,7 +336,7 @@ nfp6000_ila(uint32_t cpp_id) static inline int nfp6000_pci(uint32_t cpp_id) { - int island = NFP_CPP_ID_ISLAND_of(cpp_id); + uint8_t island = NFP_CPP_ID_ISLAND_of(cpp_id); if (island && (island < 4 || island > 7)) return NFP_ERRNO(EINVAL); @@ -354,7 +354,7 @@ nfp6000_pci(uint32_t cpp_id) static inline int nfp6000_crypto(uint32_t cpp_id) { - int island = NFP_CPP_ID_ISLAND_of(cpp_id); + uint8_t island = NFP_CPP_ID_ISLAND_of(cpp_id); if (island && (island < 12 || island > 15)) return NFP_ERRNO(EINVAL); @@ -370,9 +370,9 @@ nfp6000_crypto(uint32_t cpp_id) static inline int nfp6000_cap_xpb(uint32_t cpp_id) { - int island = NFP_CPP_ID_ISLAND_of(cpp_id); + uint8_t island = NFP_CPP_ID_ISLAND_of(cpp_id); - if (island && (island < 1 || island > 63)) + if (island > 63) return NFP_ERRNO(EINVAL); switch (cpp_id & NFP_CPP_ID(0, ~0, ~0)) { @@ -410,9 +410,9 @@ nfp6000_cap_xpb(uint32_t cpp_id) static inline int nfp6000_cls(uint32_t cpp_id) { - int island = NFP_CPP_ID_ISLAND_of(cpp_id); + uint8_t island = NFP_CPP_ID_ISLAND_of(cpp_id); - if (island && (island < 1 || island > 63)) + if (island > 63) return NFP_ERRNO(EINVAL); switch (cpp_id & NFP_CPP_ID(0, ~0, ~0)) { @@ -540,11 +540,11 @@ nfp_target_cpp(uint32_t cpp_island_id, uint64_t cpp_island_address, const uint32_t *imb_table) { int err; - int island = NFP_CPP_ID_ISLAND_of(cpp_island_id); - int target = NFP_CPP_ID_TARGET_of(cpp_island_id); + uint8_t island = NFP_CPP_ID_ISLAND_of(cpp_island_id); + uint8_t target = NFP_CPP_ID_TARGET_of(cpp_island_id); uint32_t imb; - if (target < 0 || target >= 16) + if (target >= 16) return NFP_ERRNO(EINVAL); if (island == 0) {