drivers/net/ethernet/intel/ice/ice_parser.c

Source file repositories/reference/linux-study-clean/drivers/net/ethernet/intel/ice/ice_parser.c

File Facts

System
Linux kernel
Corpus path
drivers/net/ethernet/intel/ice/ice_parser.c
Extension
.c
Size
74608 bytes
Lines
2431
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 ice_pkg_sect_hdr {
	__le16 count;
	__le16 offset;
};

/**
 * ice_parser_sect_item_get - parse an item from a section
 * @sect_type: section type
 * @section: section object
 * @index: index of the item to get
 * @offset: dummy as prototype of ice_pkg_enum_entry's last parameter
 *
 * Return: a pointer to the item or NULL.
 */
static void *ice_parser_sect_item_get(u32 sect_type, void *section,
				      u32 index, u32 __maybe_unused *offset)
{
	size_t data_off = ICE_SEC_DATA_OFFSET;
	struct ice_pkg_sect_hdr *hdr;
	size_t size;

	if (!section)
		return NULL;

	switch (sect_type) {
	case ICE_SID_RXPARSER_IMEM:
		size = ICE_SID_RXPARSER_IMEM_ENTRY_SIZE;
		break;
	case ICE_SID_RXPARSER_METADATA_INIT:
		size = ICE_SID_RXPARSER_METADATA_INIT_ENTRY_SIZE;
		break;
	case ICE_SID_RXPARSER_CAM:
		size = ICE_SID_RXPARSER_CAM_ENTRY_SIZE;
		break;
	case ICE_SID_RXPARSER_PG_SPILL:
		size = ICE_SID_RXPARSER_PG_SPILL_ENTRY_SIZE;
		break;
	case ICE_SID_RXPARSER_NOMATCH_CAM:
		size = ICE_SID_RXPARSER_NOMATCH_CAM_ENTRY_SIZE;
		break;
	case ICE_SID_RXPARSER_NOMATCH_SPILL:
		size = ICE_SID_RXPARSER_NOMATCH_SPILL_ENTRY_SIZE;
		break;
	case ICE_SID_RXPARSER_BOOST_TCAM:
		size = ICE_SID_RXPARSER_BOOST_TCAM_ENTRY_SIZE;
		break;
	case ICE_SID_LBL_RXPARSER_TMEM:
		data_off = ICE_SEC_LBL_DATA_OFFSET;
		size = ICE_SID_LBL_ENTRY_SIZE;
		break;
	case ICE_SID_RXPARSER_MARKER_PTYPE:
		size = ICE_SID_RXPARSER_MARKER_TYPE_ENTRY_SIZE;
		break;
	case ICE_SID_RXPARSER_MARKER_GRP:
		size = ICE_SID_RXPARSER_MARKER_GRP_ENTRY_SIZE;
		break;
	case ICE_SID_RXPARSER_PROTO_GRP:
		size = ICE_SID_RXPARSER_PROTO_GRP_ENTRY_SIZE;
		break;
	case ICE_SID_RXPARSER_FLAG_REDIR:
		size = ICE_SID_RXPARSER_FLAG_REDIR_ENTRY_SIZE;
		break;
	default:
		return NULL;
	}

	hdr = section;
	if (index >= le16_to_cpu(hdr->count))
		return NULL;

	return section + data_off + index * size;
}

/**
 * ice_parser_create_table - create an item table from a section
 * @hw: pointer to the hardware structure
 * @sect_type: section type
 * @item_size: item size in bytes
 * @length: number of items in the table to create
 * @parse_item: the function to parse the item
 * @no_offset: ignore header offset, calculate index from 0
 *
 * Return: a pointer to the allocated table or ERR_PTR.
 */
static void *
ice_parser_create_table(struct ice_hw *hw, u32 sect_type,
			u32 item_size, u32 length,
			void (*parse_item)(struct ice_hw *hw, u16 idx,
					   void *item, void *data,
					   int size), bool no_offset)

Annotation

Implementation Notes