src/dpdk/drivers/net/cxgbe/base/t4_hw.c
int t4_change_mac(struct adapter *adap, unsigned int mbox, unsigned int viid,
		  int idx, const u8 *addr, bool persist, bool add_smt)
{
	int ret, mode;
	struct fw_vi_mac_cmd c;
	struct fw_vi_mac_exact *p = c.u.exact;
	int max_mac_addr = adap->params.arch.mps_tcam_size;

	if (idx < 0)                             /* new allocation */
		idx = persist ? FW_VI_MAC_ADD_PERSIST_MAC : FW_VI_MAC_ADD_MAC;
	mode = add_smt ? FW_VI_MAC_SMT_AND_MPSTCAM : FW_VI_MAC_MPS_TCAM_ENTRY;

	memset(&c, 0, sizeof(c));
	c.op_to_viid = cpu_to_be32(V_FW_CMD_OP(FW_VI_MAC_CMD) |
				   F_FW_CMD_REQUEST | F_FW_CMD_WRITE |
				   V_FW_VI_MAC_CMD_VIID(viid));
	c.freemacs_to_len16 = cpu_to_be32(V_FW_CMD_LEN16(1));
	p->valid_to_idx = cpu_to_be16(F_FW_VI_MAC_CMD_VALID |
				      V_FW_VI_MAC_CMD_SMAC_RESULT(mode) |
				      V_FW_VI_MAC_CMD_IDX(idx));
	memcpy(p->macaddr, addr, sizeof(p->macaddr));

	if (is_pf4(adap))
		ret = t4_wr_mbox(adap, mbox, &c, sizeof(c), &c);
	else
		ret = t4vf_wr_mbox(adap, &c, sizeof(c), &c);
	if (ret == 0) {
		ret = G_FW_VI_MAC_CMD_IDX(be16_to_cpu(p->valid_to_idx));
		if (ret >= max_mac_addr)
			ret = -ENOMEM;
	}
	return ret;
}
/**
 * t4_change_mac - modifies the exact-match filter for a MAC address
 * @adap: the adapter
 * @mbox: mailbox to use for the FW command
 * @viid: the VI id
 * @idx: index of existing filter for old value of MAC address, or -1
 * @addr: the new MAC address value
 * @persist: whether a new MAC allocation should be persistent
 * @add_smt: if true also add the address to the HW SMT
 *
 * Modifies an exact-match filter and sets it to the new MAC address if
 * @idx >= 0, or adds the MAC address to a new filter if @idx < 0.  In the
 * latter case the address is added persistently if @persist is %true.
 *
 * Note that in general it is not possible to modify the value of a given
 * filter so the generic way to modify an address filter is to free the one
 * being used by the old address value and allocate a new filter for the
 * new address value.
 *
 * Returns a negative error number or the index of the filter with the new
 * MAC value.  Note that this index may differ from @idx.
 */


Modifies an exact-match filter and sets it to the new MAC address if
@idx >= 0, or adds the MAC address to a new filter if @idx < 0.  In the
latter case the address is added persistently if @persist is %true.

Note that in general it is not possible to modify the value of a given
filter so the generic way to modify an address filter is to free the one
being used by the old address value and allocate a new filter for the
new address value.

Returns a negative error number or the index of the filter with the new
MAC value.  Note that this index may differ from @idx.
Modifies an exact - match filter and sets it to the new MAC address if @idx > = 0 or adds the MAC address to a new filter if @idx < 0 . In the latter case the address is added persistently if @persist is %true . Note that in general it is not possible to modify the value of a given filter so the generic way to modify an address filter is to free the one being used by the old address value and allocate a new filter for the new address value . Returns a negative error number or the index of the filter with the new MAC value . Note that this index may differ from @idx .
int t4_change_mac(struct adapter *adap, unsigned int mbox, unsigned int viid,
		  int idx, const u8 *addr, bool persist, bool add_smt)
{
	int ret, mode;
	struct fw_vi_mac_cmd c;
	struct fw_vi_mac_exact *p = c.u.exact;
	int max_mac_addr = adap->params.arch.mps_tcam_size;
	if (idx < 0)                             
		idx = persist ? FW_VI_MAC_ADD_PERSIST_MAC : FW_VI_MAC_ADD_MAC;
	mode = add_smt ? FW_VI_MAC_SMT_AND_MPSTCAM : FW_VI_MAC_MPS_TCAM_ENTRY;
	memset(&c, 0, sizeof(c));
	c.op_to_viid = cpu_to_be32(V_FW_CMD_OP(FW_VI_MAC_CMD) |
				   F_FW_CMD_REQUEST | F_FW_CMD_WRITE |
				   V_FW_VI_MAC_CMD_VIID(viid));
	c.freemacs_to_len16 = cpu_to_be32(V_FW_CMD_LEN16(1));
	p->valid_to_idx = cpu_to_be16(F_FW_VI_MAC_CMD_VALID |
				      V_FW_VI_MAC_CMD_SMAC_RESULT(mode) |
				      V_FW_VI_MAC_CMD_IDX(idx));
	memcpy(p->macaddr, addr, sizeof(p->macaddr));
	if (is_pf4(adap))
		ret = t4_wr_mbox(adap, mbox, &c, sizeof(c), &c);
	else
		ret = t4vf_wr_mbox(adap, &c, sizeof(c), &c);
	if (ret == 0) {
		ret = G_FW_VI_MAC_CMD_IDX(be16_to_cpu(p->valid_to_idx));
		if (ret >= max_mac_addr)
			ret = -ENOMEM;
	}
	return ret;
}
int t4_change_mac ( struct adapter * adap , unsigned int mbox , unsigned int viid , int idx , const u8 * addr , bool persist , bool add_smt ) { int ret , mode ; struct fw_vi_mac_cmd c ; struct fw_vi_mac_exact * p = c . u . exact ; int max_mac_addr = adap -> params . arch . mps_tcam_size ; if ( idx < 0 ) idx = persist ? FW_VI_MAC_ADD_PERSIST_MAC : FW_VI_MAC_ADD_MAC ; mode = add_smt ? FW_VI_MAC_SMT_AND_MPSTCAM : FW_VI_MAC_MPS_TCAM_ENTRY ; memset ( & c , 0 , sizeof ( c ) ) ; c . op_to_viid = cpu_to_be32 ( V_FW_CMD_OP ( FW_VI_MAC_CMD ) | F_FW_CMD_REQUEST | F_FW_CMD_WRITE | V_FW_VI_MAC_CMD_VIID ( viid ) ) ; c . freemacs_to_len16 = cpu_to_be32 ( V_FW_CMD_LEN16 ( 1 ) ) ; p -> valid_to_idx = cpu_to_be16 ( F_FW_VI_MAC_CMD_VALID | V_FW_VI_MAC_CMD_SMAC_RESULT ( mode ) | V_FW_VI_MAC_CMD_IDX ( idx ) ) ; memcpy ( p -> macaddr , addr , sizeof ( p -> macaddr ) ) ; if ( is_pf4 ( adap ) ) ret = t4_wr_mbox ( adap , mbox , & c , sizeof ( c ) , & c ) ; else ret = t4vf_wr_mbox ( adap , & c , sizeof ( c ) , & c ) ; if ( ret == 0 ) { ret = G_FW_VI_MAC_CMD_IDX ( be16_to_cpu ( p -> valid_to_idx ) ) ; if ( ret >= max_mac_addr ) ret = - ENOMEM ; } return ret ; }
t4_change_mac - modifies the exact-match filter for a MAC address
 @adap: the adapter
 @mbox: mailbox to use for the FW command
 @viid: the VI id
 @idx: index of existing filter for old value of MAC address, or -1
 @addr: the new MAC address value
 @persist: whether a new MAC allocation should be persistent
 @add_smt: if true also add the address to the HW SMT
t4_change_mac - modifies the exact - match filter for a MAC address @adap : the adapter @mbox : mailbox to use for the FW command @viid : the VI id @idx : index of existing filter for old value of MAC address or - 1 @addr : the new MAC address value @persist : whether a new MAC allocation should be persistent @add_smt : if true also add the address to the HW SMT
/* new allocation */