MCPcopy Create free account
hub / github.com/F-Stack/f-stack / i40e_vsi_add_mac

Function i40e_vsi_add_mac

dpdk/drivers/net/i40e/i40e_ethdev.c:7448–7518  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7446}
7447
7448int
7449i40e_vsi_add_mac(struct i40e_vsi *vsi, struct i40e_mac_filter_info *mac_filter)
7450{
7451 struct i40e_mac_filter *f;
7452 struct i40e_macvlan_filter *mv_f;
7453 int i, vlan_num = 0;
7454 int ret = I40E_SUCCESS;
7455
7456 /* If it's add and we've config it, return */
7457 f = i40e_find_mac_filter(vsi, &mac_filter->mac_addr);
7458 if (f != NULL)
7459 return I40E_SUCCESS;
7460 if (mac_filter->filter_type == I40E_MACVLAN_PERFECT_MATCH ||
7461 mac_filter->filter_type == I40E_MACVLAN_HASH_MATCH) {
7462
7463 /**
7464 * If vlan_num is 0, that's the first time to add mac,
7465 * set mask for vlan_id 0.
7466 */
7467 if (vsi->vlan_num == 0) {
7468 i40e_set_vlan_filter(vsi, 0, 1);
7469 vsi->vlan_num = 1;
7470 }
7471 vlan_num = vsi->vlan_num;
7472 } else if (mac_filter->filter_type == I40E_MAC_PERFECT_MATCH ||
7473 mac_filter->filter_type == I40E_MAC_HASH_MATCH)
7474 vlan_num = 1;
7475
7476 mv_f = rte_zmalloc("macvlan_data", vlan_num * sizeof(*mv_f), 0);
7477 if (mv_f == NULL) {
7478 PMD_DRV_LOG(ERR, "failed to allocate memory");
7479 return I40E_ERR_NO_MEMORY;
7480 }
7481
7482 for (i = 0; i < vlan_num; i++) {
7483 mv_f[i].filter_type = mac_filter->filter_type;
7484 rte_memcpy(&mv_f[i].macaddr, &mac_filter->mac_addr,
7485 ETH_ADDR_LEN);
7486 }
7487
7488 if (mac_filter->filter_type == I40E_MACVLAN_PERFECT_MATCH ||
7489 mac_filter->filter_type == I40E_MACVLAN_HASH_MATCH) {
7490 ret = i40e_find_all_vlan_for_mac(vsi, mv_f, vlan_num,
7491 &mac_filter->mac_addr);
7492 if (ret != I40E_SUCCESS)
7493 goto DONE;
7494 }
7495
7496 ret = i40e_add_macvlan_filters(vsi, mv_f, vlan_num);
7497 if (ret != I40E_SUCCESS)
7498 goto DONE;
7499
7500 /* Add the mac addr into mac list */
7501 f = rte_zmalloc("macv_filter", sizeof(*f), 0);
7502 if (f == NULL) {
7503 PMD_DRV_LOG(ERR, "failed to allocate memory");
7504 ret = I40E_ERR_NO_MEMORY;
7505 goto DONE;

Calls 7

i40e_find_mac_filterFunction · 0.85
i40e_set_vlan_filterFunction · 0.85
rte_zmallocFunction · 0.85
i40e_add_macvlan_filtersFunction · 0.85
rte_freeFunction · 0.85
rte_memcpyFunction · 0.50

Tested by

no test coverage detected