0001
0002
0003
0004
0005
0006
0007
0008 #ifndef LMAC_COMMON_H
0009 #define LMAC_COMMON_H
0010
0011 #include "rvu.h"
0012 #include "cgx.h"
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031 struct lmac {
0032 wait_queue_head_t wq_cmd_cmplt;
0033
0034 struct mutex cmd_lock;
0035 u64 resp;
0036 struct cgx_link_user_info link_info;
0037 struct rsrc_bmap mac_to_index_bmap;
0038 struct rsrc_bmap rx_fc_pfvf_bmap;
0039 struct rsrc_bmap tx_fc_pfvf_bmap;
0040 struct cgx_event_cb event_cb;
0041
0042 spinlock_t event_cb_lock;
0043 struct cgx *cgx;
0044 u8 mcast_filters_count;
0045 u8 lmac_id;
0046 bool cmd_pend;
0047 char *name;
0048 };
0049
0050
0051
0052
0053 struct mac_ops {
0054 char *name;
0055
0056
0057
0058
0059
0060 u64 csr_offset;
0061
0062
0063
0064
0065
0066 u64 int_register;
0067 u64 int_set_reg;
0068
0069 u8 lmac_offset;
0070 u8 irq_offset;
0071 u8 int_ena_bit;
0072 u8 lmac_fwi;
0073 u32 fifo_len;
0074 bool non_contiguous_serdes_lane;
0075
0076 u8 rx_stats_cnt;
0077 u8 tx_stats_cnt;
0078
0079
0080
0081 int (*get_nr_lmacs)(void *cgx);
0082 u8 (*get_lmac_type)(void *cgx, int lmac_id);
0083 u32 (*lmac_fifo_len)(void *cgx, int lmac_id);
0084 int (*mac_lmac_intl_lbk)(void *cgx, int lmac_id,
0085 bool enable);
0086
0087 int (*mac_get_rx_stats)(void *cgx, int lmac_id,
0088 int idx, u64 *rx_stat);
0089 int (*mac_get_tx_stats)(void *cgx, int lmac_id,
0090 int idx, u64 *tx_stat);
0091
0092
0093 void (*mac_enadis_rx_pause_fwding)(void *cgxd,
0094 int lmac_id,
0095 bool enable);
0096
0097 int (*mac_get_pause_frm_status)(void *cgxd,
0098 int lmac_id,
0099 u8 *tx_pause,
0100 u8 *rx_pause);
0101
0102 int (*mac_enadis_pause_frm)(void *cgxd,
0103 int lmac_id,
0104 u8 tx_pause,
0105 u8 rx_pause);
0106
0107 void (*mac_pause_frm_config)(void *cgxd,
0108 int lmac_id,
0109 bool enable);
0110
0111
0112 void (*mac_enadis_ptp_config)(void *cgxd,
0113 int lmac_id,
0114 bool enable);
0115
0116 int (*mac_rx_tx_enable)(void *cgxd, int lmac_id, bool enable);
0117 int (*mac_tx_enable)(void *cgxd, int lmac_id, bool enable);
0118 int (*pfc_config)(void *cgxd, int lmac_id,
0119 u8 tx_pause, u8 rx_pause, u16 pfc_en);
0120
0121 int (*mac_get_pfc_frm_cfg)(void *cgxd, int lmac_id,
0122 u8 *tx_pause, u8 *rx_pause);
0123
0124 };
0125
0126 struct cgx {
0127 void __iomem *reg_base;
0128 struct pci_dev *pdev;
0129 u8 cgx_id;
0130 u8 lmac_count;
0131 struct lmac *lmac_idmap[MAX_LMAC_PER_CGX];
0132 struct work_struct cgx_cmd_work;
0133 struct workqueue_struct *cgx_cmd_workq;
0134 struct list_head cgx_list;
0135 u64 hw_features;
0136 struct mac_ops *mac_ops;
0137 unsigned long lmac_bmap;
0138
0139
0140
0141 struct mutex lock;
0142 };
0143
0144 typedef struct cgx rpm_t;
0145
0146
0147 void cgx_write(struct cgx *cgx, u64 lmac, u64 offset, u64 val);
0148 u64 cgx_read(struct cgx *cgx, u64 lmac, u64 offset);
0149 struct lmac *lmac_pdata(u8 lmac_id, struct cgx *cgx);
0150 int cgx_fwi_cmd_send(u64 req, u64 *resp, struct lmac *lmac);
0151 int cgx_fwi_cmd_generic(u64 req, u64 *resp, struct cgx *cgx, int lmac_id);
0152 bool is_lmac_valid(struct cgx *cgx, int lmac_id);
0153 struct mac_ops *rpm_get_mac_ops(void);
0154
0155 #endif