patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Huisong Li <lihuisong@huawei.com>
To: <stable@dpdk.org>, <xuemingl@nvidia.com>
Cc: <liudongdong3@huawei.com>, <fengchengwen@huawei.com>,
	<huangdaode@huawei.com>, <lihuisong@huawei.com>
Subject: [PATCH 20.11] net/hns3: support backplane media type
Date: Thu, 11 Aug 2022 18:35:23 +0800	[thread overview]
Message-ID: <20220811103523.23083-1-lihuisong@huawei.com> (raw)

From: Chengwen Feng <fengchengwen@huawei.com>

[ upstream commit 916508f002ae887942ab3b970db33c0cc7fc6c02 ]

The 802.11 physical PMA sub-layer defines three media: copper, fiber and
backplane. For PMD, the backplane is similar to the fiber, the main
differences are that backplane doesn't have optical module.

Because the interface of firmware fiber is also applicable to the
backplane, this patch supports the backplane only through simple
extension.

Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Signed-off-by: Dongdong Liu <liudongdong3@huawei.com>
---
 drivers/net/hns3/hns3_ethdev.c | 41 ++++++++++++++++++++++++++--------
 1 file changed, 32 insertions(+), 9 deletions(-)

diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c
index b2ff59ef62..f5fdcafa4f 100644
--- a/drivers/net/hns3/hns3_ethdev.c
+++ b/drivers/net/hns3/hns3_ethdev.c
@@ -3139,6 +3139,34 @@ hns3_get_capability(struct hns3_hw *hw)
 	return 0;
 }
 
+static int
+hns3_check_media_type(struct hns3_hw *hw, uint8_t media_type)
+{
+	int ret;
+
+	switch (media_type) {
+	case HNS3_MEDIA_TYPE_COPPER:
+		if (!hns3_dev_copper_supported(hw)) {
+			PMD_INIT_LOG(ERR,
+				     "Media type is copper, not supported.");
+			ret = -EOPNOTSUPP;
+		} else {
+			ret = 0;
+		}
+		break;
+	case HNS3_MEDIA_TYPE_FIBER:
+	case HNS3_MEDIA_TYPE_BACKPLANE:
+		ret = 0;
+		break;
+	default:
+		PMD_INIT_LOG(ERR, "Unknown media type = %u!", media_type);
+		ret = -EINVAL;
+		break;
+	}
+
+	return ret;
+}
+
 static int
 hns3_get_board_configuration(struct hns3_hw *hw)
 {
@@ -3153,11 +3181,9 @@ hns3_get_board_configuration(struct hns3_hw *hw)
 		return ret;
 	}
 
-	if (cfg.media_type == HNS3_MEDIA_TYPE_COPPER &&
-	    !hns3_dev_copper_supported(hw)) {
-		PMD_INIT_LOG(ERR, "media type is copper, not supported.");
-		return -EOPNOTSUPP;
-	}
+	ret = hns3_check_media_type(hw, cfg.media_type);
+	if (ret)
+		return ret;
 
 	hw->mac.media_type = cfg.media_type;
 	hw->rss_size_max = cfg.rss_size_max;
@@ -4488,14 +4514,11 @@ hns3_update_link_info(struct rte_eth_dev *eth_dev)
 {
 	struct hns3_adapter *hns = eth_dev->data->dev_private;
 	struct hns3_hw *hw = &hns->hw;
-	int ret = 0;
 
 	if (hw->mac.media_type == HNS3_MEDIA_TYPE_COPPER)
 		return 0;
-	else if (hw->mac.media_type == HNS3_MEDIA_TYPE_FIBER)
-		ret = hns3_update_fiber_link_info(hw);
 
-	return ret;
+	return hns3_update_fiber_link_info(hw);
 }
 
 static int
-- 
2.22.0


             reply	other threads:[~2022-08-11 10:36 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-11 10:35 Huisong Li [this message]
2022-08-12  7:11 ` Xueming(Steven) Li

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220811103523.23083-1-lihuisong@huawei.com \
    --to=lihuisong@huawei.com \
    --cc=fengchengwen@huawei.com \
    --cc=huangdaode@huawei.com \
    --cc=liudongdong3@huawei.com \
    --cc=stable@dpdk.org \
    --cc=xuemingl@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).