Debian Codegraph @

drivers/net/ethernet/meta/fbnic/fbnic_mac.h

raw
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Copyright (c) Meta Platforms, Inc. and affiliates. */
3
4 #ifndef _FBNIC_MAC_H_
5 #define _FBNIC_MAC_H_
6
7 #include <linux/types.h>
8
9 struct fbnic_dev;
10
11 #define FBNIC_MAX_JUMBO_FRAME_SIZE 9742
12
13 /* States loosely based on section 136.8.11.7.5 of IEEE 802.3-2022 Ethernet
14 * Standard. These are needed to track the state of the PHY as it has a delay
15 * of several seconds from the time link comes up until it has completed
16 * training that we need to wait to report the link.
17 *
18 * Currently we treat training as a single block as this is managed by the
19 * firmware.
20 *
21 * We have FBNIC_PMD_SEND_DATA set to 0 as the expected default at driver load
22 * and we initialize the structure containing it to zero at allocation.
23 */
24 enum {
25 FBNIC_PMD_SEND_DATA = 0x0,
26 FBNIC_PMD_INITIALIZE = 0x1,
27 FBNIC_PMD_TRAINING = 0x2,
28 FBNIC_PMD_LINK_READY = 0x3,
29 };
30
31 enum {
32 FBNIC_LINK_EVENT_NONE = 0,
33 FBNIC_LINK_EVENT_UP = 1,
34 FBNIC_LINK_EVENT_DOWN = 2,
35 };
36
37 /* Treat the FEC bits as a bitmask laid out as follows:
38 * Bit 0: RS Enabled
39 * Bit 1: BASER(Firecode) Enabled
40 * Bit 2: Retrieve FEC from FW
41 */
42 enum {
43 FBNIC_FEC_OFF = 0,
44 FBNIC_FEC_RS = 1,
45 FBNIC_FEC_BASER = 2,
46 };
47
48 /* Treat the AUI modes as a modulation/lanes bitmask:
49 * Bit 0: Lane Count, 0 = R1, 1 = R2
50 * Bit 1: Modulation, 0 = NRZ, 1 = PAM4
51 * Bit 2: Unknown Modulation/Lane Configuration
52 */
53 enum {
54 FBNIC_AUI_25GAUI = 0, /* 25.7812GBd 25.78125 * 1 */
55 FBNIC_AUI_LAUI2 = 1, /* 51.5625GBd 25.78128 * 2 */
56 FBNIC_AUI_50GAUI1 = 2, /* 53.125GBd 53.125 * 1 */
57 FBNIC_AUI_100GAUI2 = 3, /* 106.25GBd 53.125 * 2 */
58 FBNIC_AUI_UNKNOWN = 4,
59 __FBNIC_AUI_MAX__
60 };
61
62 #define FBNIC_AUI_MODE_R2 (FBNIC_AUI_LAUI2)
63 #define FBNIC_AUI_MODE_PAM4 (FBNIC_AUI_50GAUI1)
64
65 enum fbnic_sensor_id {
66 FBNIC_SENSOR_TEMP, /* Temp in millidegrees Centigrade */
67 FBNIC_SENSOR_VOLTAGE, /* Voltage in millivolts */
68 };
69
70 /* This structure defines the interface hooks for the MAC. The MAC hooks
71 * will be configured as a const struct provided with a set of function
72 * pointers.
73 *
74 * void (*init_regs)(struct fbnic_dev *fbd);
75 * Initialize MAC registers to enable Tx/Rx paths and FIFOs.
76 *
77 * int (*get_link_event)(struct fbnic_dev *fbd)
78 * Get the current link event status, reports true if link has
79 * changed to either FBNIC_LINK_EVENT_DOWN or FBNIC_LINK_EVENT_UP
80 * bool (*get_link)(struct fbnic_dev *fbd, u8 aui, u8 fec);
81 * Check link status
82 *
83 * void (*prepare)(struct fbnic_dev *fbd, u8 aui, u8 fec);
84 * Prepare PHY for init by fetching settings, disabling interrupts,
85 * and sending an updated PHY config to FW if needed.
86 *
87 * void (*link_down)(struct fbnic_dev *fbd);
88 * Configure MAC for link down event
89 * void (*link_up)(struct fbnic_dev *fbd, bool tx_pause, bool rx_pause);
90 * Configure MAC for link up event;
91 *
92 */
93 struct fbnic_mac {
94 void (*init_regs)(struct fbnic_dev *fbd);
95
96 int (*get_link_event)(struct fbnic_dev *fbd);
97 bool (*get_link)(struct fbnic_dev *fbd, u8 aui, u8 fec);
98
99 void (*prepare)(struct fbnic_dev *fbd, u8 aui, u8 fec);
100
101 void (*get_fec_stats)(struct fbnic_dev *fbd, bool reset,
102 struct fbnic_fec_stats *fec_stats);
103 void (*get_pcs_stats)(struct fbnic_dev *fbd, bool reset,
104 struct fbnic_pcs_stats *pcs_stats);
105 void (*get_eth_mac_stats)(struct fbnic_dev *fbd, bool reset,
106 struct fbnic_eth_mac_stats *mac_stats);
107 void (*get_pause_stats)(struct fbnic_dev *fbd, bool reset,
108 struct fbnic_pause_stats *pause_stats);
109 void (*get_eth_ctrl_stats)(struct fbnic_dev *fbd, bool reset,
110 struct fbnic_eth_ctrl_stats *ctrl_stats);
111 void (*get_rmon_stats)(struct fbnic_dev *fbd, bool reset,
112 struct fbnic_rmon_stats *rmon_stats);
113
114 void (*link_down)(struct fbnic_dev *fbd);
115 void (*link_up)(struct fbnic_dev *fbd, bool tx_pause, bool rx_pause);
116
117 int (*get_sensor)(struct fbnic_dev *fbd, int id, long *val);
118 };
119
120 int fbnic_mac_init(struct fbnic_dev *fbd);
121 void fbnic_mac_get_fw_settings(struct fbnic_dev *fbd, u8 *aui, u8 *fec);
122 #endif /* _FBNIC_MAC_H_ */