123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
#ifndef __FM_MAC_H
#define __FM_MAC_H
#include "fman.h"
#include <linux/slab.h>
#include <linux/phy.h>
#include <linux/if_ether.h>
struct fman_mac;
struct mac_device;
typedef u8 enet_addr_t[ETH_ALEN];
#define ENET_ADDR_TO_UINT64(_enet_addr) \
(u64)(((u64)(_enet_addr)[0] << 40) | \
((u64)(_enet_addr)[1] << 32) | \
((u64)(_enet_addr)[2] << 24) | \
((u64)(_enet_addr)[3] << 16) | \
((u64)(_enet_addr)[4] << 8) | \
((u64)(_enet_addr)[5]))
#define MAKE_ENET_ADDR_FROM_UINT64(_addr64, _enet_addr) \
do { \
int i; \
for (i = 0; i < ETH_ALEN; i++) \
(_enet_addr)[i] = \
(u8)((_addr64) >> ((5 - i) * 8)); \
} while (0)
#define DEFAULT_RESET_ON_INIT false
#define FSL_FM_PAUSE_TIME_ENABLE 0xf000
#define FSL_FM_PAUSE_TIME_DISABLE 0
#define FSL_FM_PAUSE_THRESH_DEFAULT 0
#define FM_MAC_NO_PFC 0xff
#define ETH_HASH_ENTRY_OBJ(ptr) \
hlist_entry_safe(ptr, struct eth_hash_entry, node)
enum fman_mac_exceptions {
FM_MAC_EX_10G_MDIO_SCAN_EVENT = 0
, FM_MAC_EX_10G_MDIO_CMD_CMPL
, FM_MAC_EX_10G_REM_FAULT
, FM_MAC_EX_10G_LOC_FAULT
, FM_MAC_EX_10G_TX_ECC_ER
, FM_MAC_EX_10G_TX_FIFO_UNFL
, FM_MAC_EX_10G_TX_FIFO_OVFL
, FM_MAC_EX_10G_TX_ER
, FM_MAC_EX_10G_RX_FIFO_OVFL
, FM_MAC_EX_10G_RX_ECC_ER
, FM_MAC_EX_10G_RX_JAB_FRM
, FM_MAC_EX_10G_RX_OVRSZ_FRM
, FM_MAC_EX_10G_RX_RUNT_FRM
, FM_MAC_EX_10G_RX_FRAG_FRM
, FM_MAC_EX_10G_RX_LEN_ER
, FM_MAC_EX_10G_RX_CRC_ER
, FM_MAC_EX_10G_RX_ALIGN_ER
, FM_MAC_EX_1G_BAB_RX
, FM_MAC_EX_1G_RX_CTL
, FM_MAC_EX_1G_GRATEFUL_TX_STP_COMPLET
, FM_MAC_EX_1G_BAB_TX
, FM_MAC_EX_1G_TX_CTL
, FM_MAC_EX_1G_TX_ERR
, FM_MAC_EX_1G_LATE_COL
, FM_MAC_EX_1G_COL_RET_LMT
, FM_MAC_EX_1G_TX_FIFO_UNDRN
, FM_MAC_EX_1G_MAG_PCKT
, FM_MAC_EX_1G_MII_MNG_RD_COMPLET
, FM_MAC_EX_1G_MII_MNG_WR_COMPLET
, FM_MAC_EX_1G_GRATEFUL_RX_STP_COMPLET
, FM_MAC_EX_1G_DATA_ERR
, FM_MAC_1G_RX_DATA_ERR
, FM_MAC_EX_1G_1588_TS_RX_ERR
, FM_MAC_EX_1G_RX_MIB_CNT_OVFL
, FM_MAC_EX_TS_FIFO_ECC_ERR
, FM_MAC_EX_MAGIC_PACKET_INDICATION = FM_MAC_EX_1G_MAG_PCKT
};
struct eth_hash_entry {
u64 addr;
struct list_head node;
};
typedef void (fman_mac_exception_cb)(struct mac_device *dev_id,
enum fman_mac_exceptions exceptions);
struct fman_mac_params {
u8 mac_id;
void *fm;
fman_mac_exception_cb *event_cb;
fman_mac_exception_cb *exception_cb;
};
struct eth_hash_t {
u16 size;
struct list_head *lsts;
};
static inline struct eth_hash_entry
*dequeue_addr_from_hash_entry(struct list_head *addr_lst)
{
struct eth_hash_entry *hash_entry = NULL;
if (!list_empty(addr_lst)) {
hash_entry = ETH_HASH_ENTRY_OBJ(addr_lst->next);
list_del_init(&hash_entry->node);
}
return hash_entry;
}
static inline void free_hash_table(struct eth_hash_t *hash)
{
struct eth_hash_entry *hash_entry;
int i = 0;
if (hash) {
if (hash->lsts) {
for (i = 0; i < hash->size; i++) {
hash_entry =
dequeue_addr_from_hash_entry(&hash->lsts[i]);
while (hash_entry) {
kfree(hash_entry);
hash_entry =
dequeue_addr_from_hash_entry(&hash->
lsts[i]);
}
}
kfree(hash->lsts);
}
kfree(hash);
}
}
static inline struct eth_hash_t *alloc_hash_table(u16 size)
{
u32 i;
struct eth_hash_t *hash;
hash = kmalloc_obj(*hash);
if (!hash)
return NULL;
hash->size = size;
hash->lsts = kmalloc_objs(struct list_head, hash->size);
if (!hash->lsts) {
kfree(hash);
return NULL;
}
for (i = 0; i < hash->size; i++)
INIT_LIST_HEAD(&hash->lsts[i]);
return hash;
}
#endif /* __FM_MAC_H */