1 /* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0) 2 * 3 * Copyright 2017 NXP 4 * 5 */ 6 7 #ifndef __FSL_FMAN_H 8 #define __FSL_FMAN_H 9 10 #include <rte_compat.h> 11 12 /* Status field in FD is updated on Rx side by FMAN with following information. 13 * Refer to field description in FM BG. 14 */ 15 struct __rte_packed_begin fm_status_t { 16 unsigned int reserved0:3; 17 unsigned int dcl4c:1; /* Don't Check L4 Checksum */ 18 unsigned int reserved1:1; 19 unsigned int ufd:1; /* Unsupported Format */ 20 unsigned int lge:1; /* Length Error */ 21 unsigned int dme:1; /* DMA Error */ 22 23 unsigned int reserved2:4; 24 unsigned int fpe:1; /* Frame physical Error */ 25 unsigned int fse:1; /* Frame Size Error */ 26 unsigned int dis:1; /* Discard by Classification */ 27 unsigned int reserved3:1; 28 29 unsigned int eof:1; /* Key Extraction goes out of frame */ 30 unsigned int nss:1; /* No Scheme selected */ 31 unsigned int kso:1; /* Key Size Overflow */ 32 unsigned int reserved4:1; 33 unsigned int fcl:2; /* Frame Color */ 34 unsigned int ipp:1; /* Illegal Policer Profile Selected */ 35 unsigned int flm:1; /* Frame Length Mismatch */ 36 unsigned int pte:1; /* Parser Timeout */ 37 unsigned int isp:1; /* Invalid Soft Parser Instruction */ 38 unsigned int phe:1; /* Header Error during parsing */ 39 unsigned int frdr:1; /* Frame Dropped by disabled port */ 40 unsigned int reserved5:4; 41 } __rte_packed_end; 42 43 /* Set MAC address for a particular interface */ 44 __rte_internal 45 int fman_if_add_mac_addr(struct fman_if *p, uint8_t *eth, uint8_t addr_num); 46 47 /* Remove a MAC address for a particular interface */ 48 __rte_internal 49 void fman_if_clear_mac_addr(struct fman_if *p, uint8_t addr_num); 50 51 /* Get the FMAN statistics */ 52 __rte_internal 53 void fman_if_stats_get(struct fman_if *p, struct rte_eth_stats *stats); 54 55 /* Reset the FMAN statistics */ 56 __rte_internal 57 void fman_if_stats_reset(struct fman_if *p); 58 59 /* Get all of the FMAN statistics */ 60 __rte_internal 61 void fman_if_stats_get_all(struct fman_if *p, uint64_t *value, int n); 62 63 __rte_internal 64 void fman_if_bmi_stats_enable(struct fman_if *p); 65 66 __rte_internal 67 void fman_if_bmi_stats_disable(struct fman_if *p); 68 69 __rte_internal 70 void fman_if_bmi_stats_get_all(struct fman_if *p, uint64_t *value); 71 72 __rte_internal 73 void fman_if_bmi_stats_reset(struct fman_if *p); 74 75 /* Set ignore pause option for a specific interface */ 76 void fman_if_set_rx_ignore_pause_frames(struct fman_if *p, bool enable); 77 78 /* Set max frame length */ 79 void fman_if_conf_max_frame_len(struct fman_if *p, unsigned int max_frame_len); 80 81 /* Enable/disable Rx promiscuous mode on specified interface */ 82 __rte_internal 83 void fman_if_promiscuous_enable(struct fman_if *p); 84 __rte_internal 85 void fman_if_promiscuous_disable(struct fman_if *p); 86 87 /* Enable/disable Rx on specific interfaces */ 88 __rte_internal 89 void fman_if_enable_rx(struct fman_if *p); 90 __rte_internal 91 void fman_if_disable_rx(struct fman_if *p); 92 __rte_internal 93 int fman_if_get_rx_status(struct fman_if *p); 94 95 /* Enable/disable loopback on specific interfaces */ 96 __rte_internal 97 void fman_if_loopback_enable(struct fman_if *p); 98 __rte_internal 99 void fman_if_loopback_disable(struct fman_if *p); 100 101 /* Set buffer pool on specific interface */ 102 __rte_internal 103 void fman_if_set_bp(struct fman_if *fm_if, unsigned int num, int bpid, 104 size_t bufsize); 105 106 /* Get Flow Control threshold parameters on specific interface */ 107 __rte_internal 108 int fman_if_get_fc_threshold(struct fman_if *fm_if); 109 110 /* Enable and Set Flow Control threshold parameters on specific interface */ 111 __rte_internal 112 int fman_if_set_fc_threshold(struct fman_if *fm_if, 113 u32 high_water, u32 low_water, u32 bpid); 114 115 /* Get Flow Control pause quanta on specific interface */ 116 __rte_internal 117 int fman_if_get_fc_quanta(struct fman_if *fm_if); 118 119 /* Set Flow Control pause quanta on specific interface */ 120 __rte_internal 121 int fman_if_set_fc_quanta(struct fman_if *fm_if, u16 pause_quanta); 122 123 /* Set default error fqid on specific interface */ 124 __rte_internal 125 void fman_if_set_err_fqid(struct fman_if *fm_if, uint32_t err_fqid); 126 127 /* Get IC transfer params */ 128 int fman_if_get_ic_params(struct fman_if *fm_if, struct fman_if_ic_params *icp); 129 130 /* Set IC transfer params */ 131 __rte_internal 132 int fman_if_set_ic_params(struct fman_if *fm_if, 133 const struct fman_if_ic_params *icp); 134 135 /* Get interface fd->offset value */ 136 __rte_internal 137 int fman_if_get_fdoff(struct fman_if *fm_if); 138 139 /* Set interface fd->offset value */ 140 __rte_internal 141 void fman_if_set_fdoff(struct fman_if *fm_if, uint32_t fd_offset); 142 143 /* Get interface SG enable status value */ 144 __rte_internal 145 int fman_if_get_sg_enable(struct fman_if *fm_if); 146 147 /* Set interface SG support mode */ 148 __rte_internal 149 void fman_if_set_sg(struct fman_if *fm_if, int enable); 150 151 /* Get interface Max Frame length (MTU) */ 152 __rte_internal 153 uint16_t fman_if_get_maxfrm(struct fman_if *fm_if); 154 155 /* Set interface Max Frame length (MTU) */ 156 __rte_internal 157 void fman_if_set_maxfrm(struct fman_if *fm_if, uint16_t max_frm); 158 159 /* Set interface next invoked action for dequeue operation */ 160 void fman_if_set_dnia(struct fman_if *fm_if, uint32_t nia); 161 162 /* discard error packets on rx */ 163 __rte_internal 164 void fman_if_discard_rx_errors(struct fman_if *fm_if); 165 166 __rte_internal 167 void fman_if_receive_rx_errors(struct fman_if *fm_if, 168 unsigned int err_eq); 169 170 __rte_internal 171 void fman_if_set_mcast_filter_table(struct fman_if *p); 172 173 __rte_internal 174 void fman_if_reset_mcast_filter_table(struct fman_if *p); 175 176 int fman_if_add_hash_mac_addr(struct fman_if *p, uint8_t *eth); 177 178 int fman_if_get_primary_mac_addr(struct fman_if *p, uint8_t *eth); 179 180 181 /* Enable/disable Rx on all interfaces */ 182 static inline void fman_if_enable_all_rx(void) 183 { 184 struct fman_if *__if; 185 186 list_for_each_entry(__if, fman_if_list, node) 187 fman_if_enable_rx(__if); 188 } 189 190 static inline void fman_if_disable_all_rx(void) 191 { 192 struct fman_if *__if; 193 194 list_for_each_entry(__if, fman_if_list, node) 195 fman_if_disable_rx(__if); 196 } 197 #endif /* __FSL_FMAN_H */ 198