Skip to content

Commit 4be1354

Browse files
SunilKumarKoriJerin Jacob
authored andcommitted
net/cnxk: report link type and status
Retrieves type of port i.e. twisted pair, fibre etc from firmware and reports the same to user. Signed-off-by: Nithin Dabilpuram <[email protected]> Signed-off-by: Sunil Kumar Kori <[email protected]>
1 parent 0e192ea commit 4be1354

File tree

3 files changed

+27
-3
lines changed

3 files changed

+27
-3
lines changed

drivers/net/cnxk/cnxk_ethdev.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,17 @@ static const uint32_t cnxk_mac_modes[CGX_MODE_MAX + 1] = {
6262
[ETH_MODE_10G_QXGMII_BIT] = RTE_ETH_LINK_SPEED_10G,
6363
};
6464

65+
static const uint8_t cnxk_port_type[] = {
66+
[CGX_PORT_TP] = RTE_ETH_LINK_CONNECTOR_TP,
67+
[CGX_PORT_AUI] = RTE_ETH_LINK_CONNECTOR_AUI,
68+
[CGX_PORT_MII] = RTE_ETH_LINK_CONNECTOR_MII,
69+
[CGX_PORT_FIBRE] = RTE_ETH_LINK_CONNECTOR_FIBER,
70+
[CGX_PORT_BNC] = RTE_ETH_LINK_CONNECTOR_BNC,
71+
[CGX_PORT_DA] = RTE_ETH_LINK_CONNECTOR_DAC,
72+
[CGX_PORT_NONE] = RTE_ETH_LINK_CONNECTOR_NONE,
73+
[CGX_PORT_OTHER] = RTE_ETH_LINK_CONNECTOR_OTHER,
74+
};
75+
6576
cnxk_ethdev_rx_offload_cb_t cnxk_ethdev_rx_offload_cb;
6677

6778
#define CNXK_NIX_CQ_INL_CLAMP_MAX (64UL * 1024UL)
@@ -98,6 +109,7 @@ static inline uint32_t
98109
nix_get_speed_capa(struct cnxk_eth_dev *dev)
99110
{
100111
struct roc_nix_mac_fwdata fwdata;
112+
struct rte_eth_link link;
101113
uint32_t speed_capa;
102114
uint8_t mode;
103115
int rc;
@@ -120,6 +132,12 @@ nix_get_speed_capa(struct cnxk_eth_dev *dev)
120132
if (fwdata.supported_link_modes & BIT_ULL(mode))
121133
speed_capa |= cnxk_mac_modes[mode];
122134
}
135+
dev->link_type = cnxk_port_type[(uint8_t)fwdata.port_type];
136+
137+
/* Set link type at init */
138+
memset(&link, 0, sizeof(link));
139+
link.link_connector = dev->link_type;
140+
rte_eth_linkstatus_set(dev->eth_dev, &link);
123141
}
124142

125143
return speed_capa;
@@ -1787,6 +1805,7 @@ cnxk_nix_dev_stop(struct rte_eth_dev *eth_dev)
17871805

17881806
/* Bring down link status internally */
17891807
memset(&link, 0, sizeof(link));
1808+
link.link_connector = dev->link_type;
17901809
rte_eth_linkstatus_set(eth_dev, &link);
17911810

17921811
return 0;

drivers/net/cnxk/cnxk_ethdev.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,7 @@ struct cnxk_eth_dev {
370370
uint64_t rx_offload_capa;
371371
uint64_t tx_offload_capa;
372372
uint32_t speed_capa;
373+
uint8_t link_type;
373374
/* Configured Rx and Tx offloads */
374375
uint64_t rx_offloads;
375376
uint64_t tx_offloads;

drivers/net/cnxk/cnxk_link.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,14 +115,16 @@ static void
115115
nix_link_status_print(struct rte_eth_dev *eth_dev, struct rte_eth_link *link)
116116
{
117117
if (link && link->link_status)
118-
plt_info("Port %d: Link Up - speed %u Mbps - %s",
118+
plt_info("Port %d: Link Up - speed %u Mbps - %s - %s",
119119
(int)(eth_dev->data->port_id),
120120
(uint32_t)link->link_speed,
121121
link->link_duplex == RTE_ETH_LINK_FULL_DUPLEX
122122
? "full-duplex"
123-
: "half-duplex");
123+
: "half-duplex",
124+
rte_eth_link_connector_to_str(link->link_connector));
124125
else
125-
plt_info("Port %d: Link Down", (int)(eth_dev->data->port_id));
126+
plt_info("Port %d: Link Down - %s", (int)(eth_dev->data->port_id),
127+
rte_eth_link_connector_to_str(link->link_connector));
126128
}
127129

128130
void
@@ -171,6 +173,7 @@ cnxk_eth_dev_link_status_cb(struct roc_nix *nix, struct roc_nix_link_info *link)
171173
eth_link.link_speed = link->speed;
172174
eth_link.link_autoneg = RTE_ETH_LINK_AUTONEG;
173175
eth_link.link_duplex = link->full_duplex;
176+
eth_link.link_connector = dev->link_type;
174177

175178
/* Print link info */
176179
nix_link_status_print(eth_dev, &eth_link);
@@ -210,6 +213,7 @@ cnxk_nix_link_update(struct rte_eth_dev *eth_dev, int wait_to_complete)
210213
link.link_autoneg = RTE_ETH_LINK_AUTONEG;
211214
if (info.full_duplex)
212215
link.link_duplex = info.full_duplex;
216+
link.link_connector = dev->link_type;
213217
}
214218

215219
return rte_eth_linkstatus_set(eth_dev, &link);

0 commit comments

Comments
 (0)