src/dpdk/drivers/net/cxgbe/base/t4_hw.c
int t4_alloc_vi_func(struct adapter *adap, unsigned int mbox,
		     unsigned int port, unsigned int pf, unsigned int vf,
		     unsigned int nmac, u8 *mac, unsigned int *rss_size,
		     unsigned int portfunc, unsigned int idstype,
		     u8 *vivld, u8 *vin)
{
	int ret;
	struct fw_vi_cmd c;

	memset(&c, 0, sizeof(c));
	c.op_to_vfn = cpu_to_be32(V_FW_CMD_OP(FW_VI_CMD) | F_FW_CMD_REQUEST |
				  F_FW_CMD_WRITE | F_FW_CMD_EXEC |
				  V_FW_VI_CMD_PFN(pf) | V_FW_VI_CMD_VFN(vf));
	c.alloc_to_len16 = cpu_to_be32(F_FW_VI_CMD_ALLOC | FW_LEN16(c));
	c.type_to_viid = cpu_to_be16(V_FW_VI_CMD_TYPE(idstype) |
				     V_FW_VI_CMD_FUNC(portfunc));
	c.portid_pkd = V_FW_VI_CMD_PORTID(port);
	c.nmac = nmac - 1;

	ret = t4_wr_mbox(adap, mbox, &c, sizeof(c), &c);
	if (ret)
		return ret;

	if (mac) {
		memcpy(mac, c.mac, sizeof(c.mac));
		switch (nmac) {
		case 5:
			memcpy(mac + 24, c.nmac3, sizeof(c.nmac3));
			/* FALLTHROUGH */
		case 4:
			memcpy(mac + 18, c.nmac2, sizeof(c.nmac2));
			/* FALLTHROUGH */
		case 3:
			memcpy(mac + 12, c.nmac1, sizeof(c.nmac1));
			/* FALLTHROUGH */
		case 2:
			memcpy(mac + 6,  c.nmac0, sizeof(c.nmac0));
			/* FALLTHROUGH */
		}
	}
	if (rss_size)
		*rss_size = G_FW_VI_CMD_RSSSIZE(be16_to_cpu(c.norss_rsssize));
	if (vivld)
		*vivld = G_FW_VI_CMD_VFVLD(be32_to_cpu(c.alloc_to_len16));
	if (vin)
		*vin = G_FW_VI_CMD_VIN(be32_to_cpu(c.alloc_to_len16));
	return G_FW_VI_CMD_VIID(cpu_to_be16(c.type_to_viid));
}
/**
 * t4_alloc_vi_func - allocate a virtual interface
 * @adap: the adapter
 * @mbox: mailbox to use for the FW command
 * @port: physical port associated with the VI
 * @pf: the PF owning the VI
 * @vf: the VF owning the VI
 * @nmac: number of MAC addresses needed (1 to 5)
 * @mac: the MAC addresses of the VI
 * @rss_size: size of RSS table slice associated with this VI
 * @portfunc: which Port Application Function MAC Address is desired
 * @idstype: Intrusion Detection Type
 *
 * Allocates a virtual interface for the given physical port.  If @mac is
 * not %NULL it contains the MAC addresses of the VI as assigned by FW.
 * @mac should be large enough to hold @nmac Ethernet addresses, they are
 * stored consecutively so the space needed is @nmac * 6 bytes.
 * Returns a negative error number or the non-negative VI id.
 */


Allocates a virtual interface for the given physical port.  If @mac is
not %NULL it contains the MAC addresses of the VI as assigned by FW.
@mac should be large enough to hold @nmac Ethernet addresses, they are
stored consecutively so the space needed is @nmac * 6 bytes.
Returns a negative error number or the non-negative VI id.
Allocates a virtual interface for the given physical port . If @mac is not %NULL it contains the MAC addresses of the VI as assigned by FW . @mac should be large enough to hold @nmac Ethernet addresses they are stored consecutively so the space needed is @nmac * 6 bytes . Returns a negative error number or the non - negative VI id .
int t4_alloc_vi_func(struct adapter *adap, unsigned int mbox,
		     unsigned int port, unsigned int pf, unsigned int vf,
		     unsigned int nmac, u8 *mac, unsigned int *rss_size,
		     unsigned int portfunc, unsigned int idstype,
		     u8 *vivld, u8 *vin)
{
	int ret;
	struct fw_vi_cmd c;
	memset(&c, 0, sizeof(c));
	c.op_to_vfn = cpu_to_be32(V_FW_CMD_OP(FW_VI_CMD) | F_FW_CMD_REQUEST |
				  F_FW_CMD_WRITE | F_FW_CMD_EXEC |
				  V_FW_VI_CMD_PFN(pf) | V_FW_VI_CMD_VFN(vf));
	c.alloc_to_len16 = cpu_to_be32(F_FW_VI_CMD_ALLOC | FW_LEN16(c));
	c.type_to_viid = cpu_to_be16(V_FW_VI_CMD_TYPE(idstype) |
				     V_FW_VI_CMD_FUNC(portfunc));
	c.portid_pkd = V_FW_VI_CMD_PORTID(port);
	c.nmac = nmac - 1;
	ret = t4_wr_mbox(adap, mbox, &c, sizeof(c), &c);
	if (ret)
		return ret;
	if (mac) {
		memcpy(mac, c.mac, sizeof(c.mac));
		switch (nmac) {
		case 5:
			memcpy(mac + 24, c.nmac3, sizeof(c.nmac3));
		case 4:
			memcpy(mac + 18, c.nmac2, sizeof(c.nmac2));
		case 3:
			memcpy(mac + 12, c.nmac1, sizeof(c.nmac1));
		case 2:
			memcpy(mac + 6,  c.nmac0, sizeof(c.nmac0));
		}
	}
	if (rss_size)
		*rss_size = G_FW_VI_CMD_RSSSIZE(be16_to_cpu(c.norss_rsssize));
	if (vivld)
		*vivld = G_FW_VI_CMD_VFVLD(be32_to_cpu(c.alloc_to_len16));
	if (vin)
		*vin = G_FW_VI_CMD_VIN(be32_to_cpu(c.alloc_to_len16));
	return G_FW_VI_CMD_VIID(cpu_to_be16(c.type_to_viid));
}
int t4_alloc_vi_func ( struct adapter * adap , unsigned int mbox , unsigned int port , unsigned int pf , unsigned int vf , unsigned int nmac , u8 * mac , unsigned int * rss_size , unsigned int portfunc , unsigned int idstype , u8 * vivld , u8 * vin ) { int ret ; struct fw_vi_cmd c ; memset ( & c , 0 , sizeof ( c ) ) ; c . op_to_vfn = cpu_to_be32 ( V_FW_CMD_OP ( FW_VI_CMD ) | F_FW_CMD_REQUEST | F_FW_CMD_WRITE | F_FW_CMD_EXEC | V_FW_VI_CMD_PFN ( pf ) | V_FW_VI_CMD_VFN ( vf ) ) ; c . alloc_to_len16 = cpu_to_be32 ( F_FW_VI_CMD_ALLOC | FW_LEN16 ( c ) ) ; c . type_to_viid = cpu_to_be16 ( V_FW_VI_CMD_TYPE ( idstype ) | V_FW_VI_CMD_FUNC ( portfunc ) ) ; c . portid_pkd = V_FW_VI_CMD_PORTID ( port ) ; c . nmac = nmac - 1 ; ret = t4_wr_mbox ( adap , mbox , & c , sizeof ( c ) , & c ) ; if ( ret ) return ret ; if ( mac ) { memcpy ( mac , c . mac , sizeof ( c . mac ) ) ; switch ( nmac ) { case 5 : memcpy ( mac + 24 , c . nmac3 , sizeof ( c . nmac3 ) ) ; case 4 : memcpy ( mac + 18 , c . nmac2 , sizeof ( c . nmac2 ) ) ; case 3 : memcpy ( mac + 12 , c . nmac1 , sizeof ( c . nmac1 ) ) ; case 2 : memcpy ( mac + 6 , c . nmac0 , sizeof ( c . nmac0 ) ) ; } } if ( rss_size ) * rss_size = G_FW_VI_CMD_RSSSIZE ( be16_to_cpu ( c . norss_rsssize ) ) ; if ( vivld ) * vivld = G_FW_VI_CMD_VFVLD ( be32_to_cpu ( c . alloc_to_len16 ) ) ; if ( vin ) * vin = G_FW_VI_CMD_VIN ( be32_to_cpu ( c . alloc_to_len16 ) ) ; return G_FW_VI_CMD_VIID ( cpu_to_be16 ( c . type_to_viid ) ) ; }
t4_alloc_vi_func - allocate a virtual interface
 @adap: the adapter
 @mbox: mailbox to use for the FW command
 @port: physical port associated with the VI
 @pf: the PF owning the VI
 @vf: the VF owning the VI
 @nmac: number of MAC addresses needed (1 to 5)
 @mac: the MAC addresses of the VI
 @rss_size: size of RSS table slice associated with this VI
 @portfunc: which Port Application Function MAC Address is desired
 @idstype: Intrusion Detection Type
t4_alloc_vi_func - allocate a virtual interface @adap : the adapter @mbox : mailbox to use for the FW command @port : physical port associated with the VI @pf : the PF owning the VI @vf : the VF owning the VI @nmac : number of MAC addresses needed ( 1 to 5 ) @mac : the MAC addresses of the VI @rss_size : size of RSS table slice associated with this VI @portfunc : which Port Application Function MAC Address is desired @idstype : Intrusion Detection Type
/* FALLTHROUGH */ /* FALLTHROUGH */ /* FALLTHROUGH */ /* FALLTHROUGH */