drivers/net/ethernet/freescale/fman/fman_mac.h

Source file repositories/reference/linux-study-clean/drivers/net/ethernet/freescale/fman/fman_mac.h

File Facts

System
Linux kernel
Corpus path
drivers/net/ethernet/freescale/fman/fman_mac.h
Extension
.h
Size
7452 bytes
Lines
246
Domain
Driver Families
Bucket
drivers/net
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

struct eth_hash_entry {
	u64 addr;		/* Ethernet Address  */
	struct list_head node;
};

typedef void (fman_mac_exception_cb)(struct mac_device *dev_id,
				     enum fman_mac_exceptions exceptions);

/* FMan MAC config input */
struct fman_mac_params {
	/* MAC ID; numbering of dTSEC and 1G-mEMAC:
	 * 0 - FM_MAX_NUM_OF_1G_MACS;
	 * numbering of 10G-MAC (TGEC) and 10G-mEMAC:
	 * 0 - FM_MAX_NUM_OF_10G_MACS
	 */
	u8 mac_id;
	/* A handle to the FM object this port related to */
	void *fm;
	fman_mac_exception_cb *event_cb;    /* MDIO Events Callback Routine */
	fman_mac_exception_cb *exception_cb;/* Exception Callback Routine */
};

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;

	/* Allocate address hash table */
	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 */

Annotation

Implementation Notes