Commit 4c116f85 authored by Guangbin Huang's avatar Guangbin Huang Committed by David S. Miller

net: hns3: add macros for mac speeds of firmware command

To improve code readability, replace digital numbers of mac speeds
defined by firmware command with macros.
Signed-off-by: default avatarGuangbin Huang <huangguangbin2@huawei.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent fe50893a
...@@ -1201,6 +1201,19 @@ struct hclge_dev_specs_1_cmd { ...@@ -1201,6 +1201,19 @@ struct hclge_dev_specs_1_cmd {
u8 rsv1[18]; u8 rsv1[18];
}; };
/* mac speed type defined in firmware command */
enum HCLGE_FIRMWARE_MAC_SPEED {
HCLGE_FW_MAC_SPEED_1G,
HCLGE_FW_MAC_SPEED_10G,
HCLGE_FW_MAC_SPEED_25G,
HCLGE_FW_MAC_SPEED_40G,
HCLGE_FW_MAC_SPEED_50G,
HCLGE_FW_MAC_SPEED_100G,
HCLGE_FW_MAC_SPEED_10M,
HCLGE_FW_MAC_SPEED_100M,
HCLGE_FW_MAC_SPEED_200G,
};
#define HCLGE_PHY_LINK_SETTING_BD_NUM 2 #define HCLGE_PHY_LINK_SETTING_BD_NUM 2
struct hclge_phy_link_ksetting_0_cmd { struct hclge_phy_link_ksetting_0_cmd {
......
...@@ -959,31 +959,31 @@ static int hclge_query_pf_resource(struct hclge_dev *hdev) ...@@ -959,31 +959,31 @@ static int hclge_query_pf_resource(struct hclge_dev *hdev)
static int hclge_parse_speed(u8 speed_cmd, u32 *speed) static int hclge_parse_speed(u8 speed_cmd, u32 *speed)
{ {
switch (speed_cmd) { switch (speed_cmd) {
case 6: case HCLGE_FW_MAC_SPEED_10M:
*speed = HCLGE_MAC_SPEED_10M; *speed = HCLGE_MAC_SPEED_10M;
break; break;
case 7: case HCLGE_FW_MAC_SPEED_100M:
*speed = HCLGE_MAC_SPEED_100M; *speed = HCLGE_MAC_SPEED_100M;
break; break;
case 0: case HCLGE_FW_MAC_SPEED_1G:
*speed = HCLGE_MAC_SPEED_1G; *speed = HCLGE_MAC_SPEED_1G;
break; break;
case 1: case HCLGE_FW_MAC_SPEED_10G:
*speed = HCLGE_MAC_SPEED_10G; *speed = HCLGE_MAC_SPEED_10G;
break; break;
case 2: case HCLGE_FW_MAC_SPEED_25G:
*speed = HCLGE_MAC_SPEED_25G; *speed = HCLGE_MAC_SPEED_25G;
break; break;
case 3: case HCLGE_FW_MAC_SPEED_40G:
*speed = HCLGE_MAC_SPEED_40G; *speed = HCLGE_MAC_SPEED_40G;
break; break;
case 4: case HCLGE_FW_MAC_SPEED_50G:
*speed = HCLGE_MAC_SPEED_50G; *speed = HCLGE_MAC_SPEED_50G;
break; break;
case 5: case HCLGE_FW_MAC_SPEED_100G:
*speed = HCLGE_MAC_SPEED_100G; *speed = HCLGE_MAC_SPEED_100G;
break; break;
case 8: case HCLGE_FW_MAC_SPEED_200G:
*speed = HCLGE_MAC_SPEED_200G; *speed = HCLGE_MAC_SPEED_200G;
break; break;
default: default:
...@@ -2582,39 +2582,39 @@ static int hclge_cfg_mac_speed_dup_hw(struct hclge_dev *hdev, int speed, ...@@ -2582,39 +2582,39 @@ static int hclge_cfg_mac_speed_dup_hw(struct hclge_dev *hdev, int speed,
switch (speed) { switch (speed) {
case HCLGE_MAC_SPEED_10M: case HCLGE_MAC_SPEED_10M:
hnae3_set_field(req->speed_dup, HCLGE_CFG_SPEED_M, hnae3_set_field(req->speed_dup, HCLGE_CFG_SPEED_M,
HCLGE_CFG_SPEED_S, 6); HCLGE_CFG_SPEED_S, HCLGE_FW_MAC_SPEED_10M);
break; break;
case HCLGE_MAC_SPEED_100M: case HCLGE_MAC_SPEED_100M:
hnae3_set_field(req->speed_dup, HCLGE_CFG_SPEED_M, hnae3_set_field(req->speed_dup, HCLGE_CFG_SPEED_M,
HCLGE_CFG_SPEED_S, 7); HCLGE_CFG_SPEED_S, HCLGE_FW_MAC_SPEED_100M);
break; break;
case HCLGE_MAC_SPEED_1G: case HCLGE_MAC_SPEED_1G:
hnae3_set_field(req->speed_dup, HCLGE_CFG_SPEED_M, hnae3_set_field(req->speed_dup, HCLGE_CFG_SPEED_M,
HCLGE_CFG_SPEED_S, 0); HCLGE_CFG_SPEED_S, HCLGE_FW_MAC_SPEED_1G);
break; break;
case HCLGE_MAC_SPEED_10G: case HCLGE_MAC_SPEED_10G:
hnae3_set_field(req->speed_dup, HCLGE_CFG_SPEED_M, hnae3_set_field(req->speed_dup, HCLGE_CFG_SPEED_M,
HCLGE_CFG_SPEED_S, 1); HCLGE_CFG_SPEED_S, HCLGE_FW_MAC_SPEED_10G);
break; break;
case HCLGE_MAC_SPEED_25G: case HCLGE_MAC_SPEED_25G:
hnae3_set_field(req->speed_dup, HCLGE_CFG_SPEED_M, hnae3_set_field(req->speed_dup, HCLGE_CFG_SPEED_M,
HCLGE_CFG_SPEED_S, 2); HCLGE_CFG_SPEED_S, HCLGE_FW_MAC_SPEED_25G);
break; break;
case HCLGE_MAC_SPEED_40G: case HCLGE_MAC_SPEED_40G:
hnae3_set_field(req->speed_dup, HCLGE_CFG_SPEED_M, hnae3_set_field(req->speed_dup, HCLGE_CFG_SPEED_M,
HCLGE_CFG_SPEED_S, 3); HCLGE_CFG_SPEED_S, HCLGE_FW_MAC_SPEED_40G);
break; break;
case HCLGE_MAC_SPEED_50G: case HCLGE_MAC_SPEED_50G:
hnae3_set_field(req->speed_dup, HCLGE_CFG_SPEED_M, hnae3_set_field(req->speed_dup, HCLGE_CFG_SPEED_M,
HCLGE_CFG_SPEED_S, 4); HCLGE_CFG_SPEED_S, HCLGE_FW_MAC_SPEED_50G);
break; break;
case HCLGE_MAC_SPEED_100G: case HCLGE_MAC_SPEED_100G:
hnae3_set_field(req->speed_dup, HCLGE_CFG_SPEED_M, hnae3_set_field(req->speed_dup, HCLGE_CFG_SPEED_M,
HCLGE_CFG_SPEED_S, 5); HCLGE_CFG_SPEED_S, HCLGE_FW_MAC_SPEED_100G);
break; break;
case HCLGE_MAC_SPEED_200G: case HCLGE_MAC_SPEED_200G:
hnae3_set_field(req->speed_dup, HCLGE_CFG_SPEED_M, hnae3_set_field(req->speed_dup, HCLGE_CFG_SPEED_M,
HCLGE_CFG_SPEED_S, 8); HCLGE_CFG_SPEED_S, HCLGE_FW_MAC_SPEED_200G);
break; break;
default: default:
dev_err(&hdev->pdev->dev, "invalid speed (%d)\n", speed); dev_err(&hdev->pdev->dev, "invalid speed (%d)\n", speed);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment