xref: /dpdk/drivers/net/ntnic/include/nt4ga_link.h (revision 51052594f79568b8489f3d6cf3fb4c79ebf33f56)
1 /*
2  * SPDX-License-Identifier: BSD-3-Clause
3  * Copyright(c) 2023 Napatech A/S
4  */
5 
6 #ifndef NT4GA_LINK_H_
7 #define NT4GA_LINK_H_
8 
9 #include "ntos_drv.h"
10 #include "ntnic_nim.h"
11 
12 enum nt_link_state_e {
13 	NT_LINK_STATE_UNKNOWN = 0,	/* The link state has not been read yet */
14 	NT_LINK_STATE_DOWN = 1,	/* The link state is DOWN */
15 	NT_LINK_STATE_UP = 2,	/* The link state is UP */
16 	NT_LINK_STATE_ERROR = 3	/* The link state could not be read */
17 };
18 
19 typedef enum nt_link_state_e nt_link_state_t, *nt_link_state_p;
20 
21 enum nt_link_duplex_e {
22 	NT_LINK_DUPLEX_UNKNOWN = 0,
23 	NT_LINK_DUPLEX_HALF = 0x01,	/* Half duplex */
24 	NT_LINK_DUPLEX_FULL = 0x02,	/* Full duplex */
25 };
26 
27 typedef enum nt_link_duplex_e nt_link_duplex_t;
28 
29 enum nt_link_loopback_e {
30 	NT_LINK_LOOPBACK_OFF = 0,
31 	NT_LINK_LOOPBACK_HOST = 0x01,	/* Host loopback mode */
32 	NT_LINK_LOOPBACK_LINE = 0x02,	/* Line loopback mode */
33 };
34 
35 enum nt_link_auto_neg_e {
36 	NT_LINK_AUTONEG_NA = 0,
37 	NT_LINK_AUTONEG_MANUAL = 0x01,
38 	NT_LINK_AUTONEG_OFF = NT_LINK_AUTONEG_MANUAL,	/* Auto negotiation OFF */
39 	NT_LINK_AUTONEG_AUTO = 0x02,
40 	NT_LINK_AUTONEG_ON = NT_LINK_AUTONEG_AUTO,	/* Auto negotiation ON */
41 };
42 
43 typedef struct link_state_s {
44 	bool link_disabled;
45 	bool nim_present;
46 	bool lh_nim_absent;
47 	bool link_up;
48 	enum nt_link_state_e link_state;
49 	enum nt_link_state_e link_state_latched;
50 } link_state_t;
51 
52 enum nt_link_speed_e {
53 	NT_LINK_SPEED_UNKNOWN = 0,
54 	NT_LINK_SPEED_10M = 0x01,	/* 10 Mbps */
55 	NT_LINK_SPEED_100M = 0x02,	/* 100 Mbps */
56 	NT_LINK_SPEED_1G = 0x04,/* 1 Gbps  (Autoneg only) */
57 	NT_LINK_SPEED_10G = 0x08,	/* 10 Gbps (Autoneg only) */
58 	NT_LINK_SPEED_40G = 0x10,	/* 40 Gbps (Autoneg only) */
59 	NT_LINK_SPEED_100G = 0x20,	/* 100 Gbps (Autoneg only) */
60 	NT_LINK_SPEED_50G = 0x40,	/* 50 Gbps (Autoneg only) */
61 	NT_LINK_SPEED_25G = 0x80,	/* 25 Gbps (Autoneg only) */
62 	NT_LINK_SPEED_END	/* always keep this entry as the last in enum */
63 };
64 typedef enum nt_link_speed_e nt_link_speed_t;
65 
66 typedef struct link_info_s {
67 	enum nt_link_speed_e link_speed;
68 	enum nt_link_duplex_e link_duplex;
69 	enum nt_link_auto_neg_e link_auto_neg;
70 } link_info_t;
71 
72 typedef struct port_action_s {
73 	bool port_disable;
74 	enum nt_link_speed_e port_speed;
75 	enum nt_link_duplex_e port_duplex;
76 	uint32_t port_lpbk_mode;
77 } port_action_t;
78 
79 typedef struct adapter_100g_s {
80 	nim_i2c_ctx_t nim_ctx[NUM_ADAPTER_PORTS_MAX];	/* Should be the first field */
81 	nthw_mac_pcs_t mac_pcs100g[NUM_ADAPTER_PORTS_MAX];
82 	nthw_gpio_phy_t gpio_phy[NUM_ADAPTER_PORTS_MAX];
83 } adapter_100g_t;
84 
85 typedef union adapter_var_s {
86 	nim_i2c_ctx_t nim_ctx[NUM_ADAPTER_PORTS_MAX];	/* First field in all the adapters type */
87 	adapter_100g_t var100g;
88 } adapter_var_u;
89 
90 typedef struct nt4ga_link_s {
91 	link_state_t link_state[NUM_ADAPTER_PORTS_MAX];
92 	link_info_t link_info[NUM_ADAPTER_PORTS_MAX];
93 	port_action_t port_action[NUM_ADAPTER_PORTS_MAX];
94 	uint32_t speed_capa;
95 	bool variables_initialized;
96 	adapter_var_u u;
97 } nt4ga_link_t;
98 
99 #endif	/* NT4GA_LINK_H_ */
100