drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_pf.c

Source file repositories/reference/linux-study-clean/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_pf.c

File Facts

System
Linux kernel
Corpus path
drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_pf.c
Extension
.c
Size
51059 bytes
Lines
2047
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 qlcnic_sriov_cmd_handler {
	int (*fn) (struct qlcnic_bc_trans *, struct qlcnic_cmd_args *);
};

struct qlcnic_sriov_fw_cmd_handler {
	u32 cmd;
	int (*fn) (struct qlcnic_bc_trans *, struct qlcnic_cmd_args *);
};

static int qlcnic_sriov_pf_set_vport_info(struct qlcnic_adapter *adapter,
					  struct qlcnic_info *npar_info,
					  u16 vport_id)
{
	struct qlcnic_cmd_args cmd;
	int err;

	if (qlcnic_alloc_mbx_args(&cmd, adapter, QLCNIC_CMD_SET_NIC_INFO))
		return -ENOMEM;

	cmd.req.arg[1] = (vport_id << 16) | 0x1;
	cmd.req.arg[2] = npar_info->bit_offsets;
	cmd.req.arg[2] |= npar_info->min_tx_bw << 16;
	cmd.req.arg[3] = npar_info->max_tx_bw | (npar_info->max_tx_ques << 16);
	cmd.req.arg[4] = npar_info->max_tx_mac_filters;
	cmd.req.arg[4] |= npar_info->max_rx_mcast_mac_filters << 16;
	cmd.req.arg[5] = npar_info->max_rx_ucast_mac_filters |
			 (npar_info->max_rx_ip_addr << 16);
	cmd.req.arg[6] = npar_info->max_rx_lro_flow |
			 (npar_info->max_rx_status_rings << 16);
	cmd.req.arg[7] = npar_info->max_rx_buf_rings |
			 (npar_info->max_rx_ques << 16);
	cmd.req.arg[8] = npar_info->max_tx_vlan_keys;
	cmd.req.arg[8] |= npar_info->max_local_ipv6_addrs << 16;
	cmd.req.arg[9] = npar_info->max_remote_ipv6_addrs;

	err = qlcnic_issue_cmd(adapter, &cmd);
	if (err)
		dev_err(&adapter->pdev->dev,
			"Failed to set vport info, err=%d\n", err);

	qlcnic_free_mbx_args(&cmd);
	return err;
}

static int qlcnic_sriov_pf_cal_res_limit(struct qlcnic_adapter *adapter,
					 struct qlcnic_info *info, u16 func)
{
	struct qlcnic_sriov *sriov = adapter->ahw->sriov;
	struct qlcnic_resources *res = &sriov->ff_max;
	u16 num_macs = sriov->num_allowed_vlans + 1;
	int ret = -EIO, vpid, id;
	struct qlcnic_vport *vp;
	u32 num_vfs, max, temp;

	vpid = qlcnic_sriov_pf_get_vport_handle(adapter, func);
	if (vpid < 0)
		return -EINVAL;

	num_vfs = sriov->num_vfs;
	max = num_vfs + 1;
	info->bit_offsets = 0xffff;
	info->max_tx_ques = res->num_tx_queues / max;

	if (qlcnic_83xx_pf_check(adapter))
		num_macs = QLCNIC_83XX_SRIOV_VF_MAX_MAC;

	info->max_rx_mcast_mac_filters = res->num_rx_mcast_mac_filters;

	if (adapter->ahw->pci_func == func) {
		info->min_tx_bw = 0;
		info->max_tx_bw = MAX_BW;

		temp = res->num_rx_ucast_mac_filters - num_macs * num_vfs;
		info->max_rx_ucast_mac_filters = temp;
		temp = res->num_tx_mac_filters - num_macs * num_vfs;
		info->max_tx_mac_filters = temp;
		temp = num_macs * num_vfs * QLCNIC_SRIOV_VF_MAX_MAC;
		temp = res->num_rx_mcast_mac_filters - temp;
		info->max_rx_mcast_mac_filters = temp;

		info->max_tx_ques = res->num_tx_queues - sriov->num_vfs;
	} else {
		id = qlcnic_sriov_func_to_index(adapter, func);
		if (id < 0)
			return id;
		vp = sriov->vf_info[id].vp;
		info->min_tx_bw = vp->min_tx_bw;
		info->max_tx_bw = vp->max_tx_bw;

		info->max_rx_ucast_mac_filters = num_macs;

Annotation

Implementation Notes