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 enum { 14 FBNIC_LINK_EVENT_NONE = 0, 15 FBNIC_LINK_EVENT_UP = 1, 16 FBNIC_LINK_EVENT_DOWN = 2, 17 }; 18 19 /* Treat the FEC bits as a bitmask laid out as follows: 20 * Bit 0: RS Enabled 21 * Bit 1: BASER(Firecode) Enabled 22 * Bit 2: Retrieve FEC from FW 23 */ 24 enum { 25 FBNIC_FEC_OFF = 0, 26 FBNIC_FEC_RS = 1, 27 FBNIC_FEC_BASER = 2, 28 FBNIC_FEC_AUTO = 4, 29 }; 30 31 #define FBNIC_FEC_MODE_MASK (FBNIC_FEC_AUTO - 1) 32 33 /* Treat the link modes as a set of modulation/lanes bitmask: 34 * Bit 0: Lane Count, 0 = R1, 1 = R2 35 * Bit 1: Modulation, 0 = NRZ, 1 = PAM4 36 * Bit 2: Retrieve link mode from FW 37 */ 38 enum { 39 FBNIC_LINK_25R1 = 0, 40 FBNIC_LINK_50R2 = 1, 41 FBNIC_LINK_50R1 = 2, 42 FBNIC_LINK_100R2 = 3, 43 FBNIC_LINK_AUTO = 4, 44 }; 45 46 #define FBNIC_LINK_MODE_R2 (FBNIC_LINK_50R2) 47 #define FBNIC_LINK_MODE_PAM4 (FBNIC_LINK_50R1) 48 #define FBNIC_LINK_MODE_MASK (FBNIC_LINK_AUTO - 1) 49 50 /* This structure defines the interface hooks for the MAC. The MAC hooks 51 * will be configured as a const struct provided with a set of function 52 * pointers. 53 * 54 * void (*init_regs)(struct fbnic_dev *fbd); 55 * Initialize MAC registers to enable Tx/Rx paths and FIFOs. 56 * 57 * void (*pcs_enable)(struct fbnic_dev *fbd); 58 * Configure and enable PCS to enable link if not already enabled 59 * void (*pcs_disable)(struct fbnic_dev *fbd); 60 * Shutdown the link if we are the only consumer of it. 61 * bool (*pcs_get_link)(struct fbnic_dev *fbd); 62 * Check PCS link status 63 * int (*pcs_get_link_event)(struct fbnic_dev *fbd) 64 * Get the current link event status, reports true if link has 65 * changed to either FBNIC_LINK_EVENT_DOWN or FBNIC_LINK_EVENT_UP 66 * 67 * void (*link_down)(struct fbnic_dev *fbd); 68 * Configure MAC for link down event 69 * void (*link_up)(struct fbnic_dev *fbd, bool tx_pause, bool rx_pause); 70 * Configure MAC for link up event; 71 * 72 */ 73 struct fbnic_mac { 74 void (*init_regs)(struct fbnic_dev *fbd); 75 76 int (*pcs_enable)(struct fbnic_dev *fbd); 77 void (*pcs_disable)(struct fbnic_dev *fbd); 78 bool (*pcs_get_link)(struct fbnic_dev *fbd); 79 int (*pcs_get_link_event)(struct fbnic_dev *fbd); 80 81 void (*get_eth_mac_stats)(struct fbnic_dev *fbd, bool reset, 82 struct fbnic_eth_mac_stats *mac_stats); 83 84 void (*link_down)(struct fbnic_dev *fbd); 85 void (*link_up)(struct fbnic_dev *fbd, bool tx_pause, bool rx_pause); 86 }; 87 88 int fbnic_mac_init(struct fbnic_dev *fbd); 89 #endif /* _FBNIC_MAC_H_ */ 90