Lines Matching refs:mac
156 #define MACREG(mac, mac_reg) ((mac)->instance->mac_base + (mac_reg))
165 static void disable_port(struct cmac *mac)
169 (void) t1_tpi_read(mac->adapter, REG_PORT_ENABLE, &val);
170 val &= ~(1 << mac->instance->index);
171 (void) t1_tpi_write(mac->adapter, REG_PORT_ENABLE, val);
174 #define RMON_UPDATE(mac, name, stat_name) \
175 (void) t1_tpi_read((mac)->adapter, MACREG(mac, REG_##name), &val); \
176 (mac)->stats.stat_name += val;
182 static void port_stats_update(struct cmac *mac)
187 RMON_UPDATE(mac, RxOctetsTotalOK, RxOctetsOK);
188 RMON_UPDATE(mac, RxOctetsBad, RxOctetsBad);
189 RMON_UPDATE(mac, RxUCPkts, RxUnicastFramesOK);
190 RMON_UPDATE(mac, RxMCPkts, RxMulticastFramesOK);
191 RMON_UPDATE(mac, RxBCPkts, RxBroadcastFramesOK);
192 RMON_UPDATE(mac, RxJumboPkts, RxJumboFramesOK);
193 RMON_UPDATE(mac, RxFCSErrors, RxFCSErrors);
194 RMON_UPDATE(mac, RxAlignErrors, RxAlignErrors);
195 RMON_UPDATE(mac, RxLongErrors, RxFrameTooLongErrors);
196 RMON_UPDATE(mac, RxVeryLongErrors, RxFrameTooLongErrors);
197 RMON_UPDATE(mac, RxPauseMacControlCounter, RxPauseFrames);
198 RMON_UPDATE(mac, RxDataErrors, RxDataErrors);
199 RMON_UPDATE(mac, RxJabberErrors, RxJabberErrors);
200 RMON_UPDATE(mac, RxRuntErrors, RxRuntErrors);
201 RMON_UPDATE(mac, RxShortErrors, RxRuntErrors);
202 RMON_UPDATE(mac, RxSequenceErrors, RxSequenceErrors);
203 RMON_UPDATE(mac, RxSymbolErrors, RxSymbolErrors);
206 RMON_UPDATE(mac, TxOctetsTotalOK, TxOctetsOK);
207 RMON_UPDATE(mac, TxOctetsBad, TxOctetsBad);
208 RMON_UPDATE(mac, TxUCPkts, TxUnicastFramesOK);
209 RMON_UPDATE(mac, TxMCPkts, TxMulticastFramesOK);
210 RMON_UPDATE(mac, TxBCPkts, TxBroadcastFramesOK);
211 RMON_UPDATE(mac, TxJumboPkts, TxJumboFramesOK);
212 RMON_UPDATE(mac, TxPauseFrames, TxPauseFrames);
213 RMON_UPDATE(mac, TxExcessiveLengthDrop, TxLengthErrors);
214 RMON_UPDATE(mac, TxUnderrun, TxUnderrun);
215 RMON_UPDATE(mac, TxCRCErrors, TxFCSErrors);
220 static int mac_intr_op(struct cmac *mac)
226 static int mac_set_address(struct cmac *mac, u8 addr[6])
238 (void) t1_tpi_write(mac->adapter, MACREG(mac, REG_MACADDR_LOW), addr_lo);
239 (void) t1_tpi_write(mac->adapter, MACREG(mac, REG_MACADDR_HIGH), addr_hi);
243 static int mac_get_address(struct cmac *mac, u8 addr[6])
247 (void) t1_tpi_read(mac->adapter, MACREG(mac, REG_MACADDR_LOW), &addr_lo);
248 (void) t1_tpi_read(mac->adapter, MACREG(mac, REG_MACADDR_HIGH), &addr_hi);
261 static int mac_reset(struct cmac *mac)
266 static int mac_set_rx_mode(struct cmac *mac, struct t1_rx_mode *rm)
269 adapter_t *adapter = mac->adapter;
273 (void) t1_tpi_read(adapter, MACREG(mac, REG_RX_FILTER), &val);
275 if (!t1_rx_mode_promisc(rm) && mac->instance->version > 0)
281 (void) t1_tpi_write(adapter, MACREG(mac, REG_RX_FILTER), new_mode);
284 (void) t1_tpi_write(adapter, MACREG(mac, REG_MC_ADDR_LOW), 0);
285 (void) t1_tpi_write(adapter, MACREG(mac, REG_MC_ADDR_HIGH), 0);
292 (void) t1_tpi_write(adapter, MACREG(mac, REG_MC_ADDR_LOW), addr_lo);
293 (void) t1_tpi_write(adapter, MACREG(mac, REG_MC_ADDR_HIGH), addr_hi);
301 static int mac_set_mtu(struct cmac *mac, int mtu)
305 (void) t1_tpi_write(mac->adapter, MACREG(mac, REG_MAX_FRAME_SIZE),
310 static int mac_set_speed_duplex_fc(struct cmac *mac, int speed, int duplex,
322 (void) t1_tpi_write(mac->adapter, MACREG(mac, REG_RGMII_SPEED), val);
325 (void) t1_tpi_read(mac->adapter, MACREG(mac, REG_FC_ENABLE), &val);
331 (void) t1_tpi_write(mac->adapter, MACREG(mac, REG_FC_ENABLE), val);
335 static int mac_get_speed_duplex_fc(struct cmac *mac, int *speed, int *duplex,
343 (void) t1_tpi_read(mac->adapter, MACREG(mac, REG_RGMII_SPEED),
348 (void) t1_tpi_read(mac->adapter, MACREG(mac, REG_FC_ENABLE), &val);
358 static void enable_port(struct cmac *mac)
361 u32 index = mac->instance->index;
362 adapter_t *adapter = mac->adapter;
364 (void) t1_tpi_read(adapter, MACREG(mac, REG_DIVERSE_CONFIG), &val);
366 (void) t1_tpi_write(adapter, MACREG(mac, REG_DIVERSE_CONFIG), val);
367 if (mac->instance->version > 0)
368 (void) t1_tpi_write(adapter, MACREG(mac, REG_RX_FILTER), 3);
370 (void) t1_tpi_write(adapter, MACREG(mac, REG_RX_FILTER), 2);
380 port_stats_update(mac);
381 (void) memset(&mac->stats, 0, sizeof(struct cmac_statistics));
382 mac->instance->ticks = 0;
403 TX_FIFO_XFER_THRES_BASE + mac->instance->index * 4, 0x400);
408 static int mac_enable(struct cmac *mac, int which)
411 enable_port(mac);
415 static int mac_disable(struct cmac *mac, int which)
418 disable_port(mac);
431 static const struct cmac_statistics *mac_update_statistics(struct cmac *mac,
435 MAJOR_UPDATE_TICKS <= mac->instance->ticks) {
436 port_stats_update(mac);
437 mac->instance->ticks = 0;
441 RMON_UPDATE(mac, RxOctetsTotalOK, RxOctetsOK);
442 RMON_UPDATE(mac, TxOctetsTotalOK, TxOctetsOK);
443 mac->instance->ticks++;
445 return &mac->stats;
448 static void mac_destroy(struct cmac *mac)
450 t1_os_free((void *)mac, sizeof(*mac) + sizeof(cmac_instance));
512 struct cmac *mac;
517 mac = t1_os_malloc_wait_zero(sizeof(*mac) + sizeof(cmac_instance));
518 if (!mac) return NULL;
520 mac->ops = &ixf1010_ops;
521 mac->instance = (cmac_instance *)(mac + 1);
523 mac->instance->mac_base = MACREG_BASE + (index * 0x200);
524 mac->instance->index = index;
525 mac->adapter = adapter;
526 mac->instance->ticks = 0;
529 mac->instance->version = val >> 28;
530 return mac;