> -----Original Message-----
> From: dev [mailto:[email protected]] On Behalf Of Wenzhuo Lu
> Sent: Wednesday, December 12, 2018 3:00 PM
> To: [email protected]
> Cc: Lu, Wenzhuo <[email protected]>; Yang, Qiming
> <[email protected]>; Li, Xiaoyun <[email protected]>; Wu, Jingjing
> <[email protected]>
> Subject: [dpdk-dev] [PATCH v3 22/34] net/ice: support MAC ops
> 
> Add below ops,
> mac_addr_set
> mac_addr_add
> mac_addr_remove
> 
> Signed-off-by: Wenzhuo Lu <[email protected]>
> Signed-off-by: Qiming Yang <[email protected]>
> Signed-off-by: Xiaoyun Li <[email protected]>
> Signed-off-by: Jingjing Wu <[email protected]>

.....


> ---
>  drivers/net/ice/ice_ethdev.c | 233
> +++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 233 insertions(+)
>
> +static int ice_macaddr_set(struct rte_eth_dev *dev,
> +                        struct ether_addr *mac_addr)
> +{
> +     struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
> +     struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
> +     struct ice_vsi *vsi = pf->main_vsi;
> +     struct ice_mac_filter *f;
> +     uint8_t flags = 0;
> +     int ret;
> +
> +     if (!is_valid_assigned_ether_addr(mac_addr)) {
> +             PMD_DRV_LOG(ERR, "Tried to set invalid MAC address.");
> +             return -EINVAL;
> +     }
> +
> +     TAILQ_FOREACH(f, &vsi->mac_list, next) {
> +             if (is_same_ether_addr(&pf->dev_addr, &f->mac_info.mac_addr))
> +                     break;
> +     }
> +
> +     if (!f) {
> +             PMD_DRV_LOG(ERR, "Failed to find filter for default mac");
> +             return -EIO;
> +     }
> +
> +     ret = ice_remove_mac_filter(vsi, &f->mac_info.mac_addr);
> +     if (ret != ICE_SUCCESS) {
> +             PMD_DRV_LOG(ERR, "Failed to delete mac filter");
> +             return -EIO;
> +     }
> +     ret = ice_add_mac_filter(vsi, mac_addr);
> +     if (ret != ICE_SUCCESS) {
> +             PMD_DRV_LOG(ERR, "Failed to add mac filter");
> +             return -EIO;
> +     }
> +     memcpy(&pf->dev_addr, mac_addr, ETH_ADDR_LEN);
> +
> +     flags = ICE_AQC_MAN_MAC_UPDATE_LAA_WOL;
> +     ice_aq_manage_mac_write(hw, mac_addr->addr_bytes, flags, NULL);

Should check return value of the AQ command in case some error happen?

> +
> +     return 0;
> +}
> +

Reply via email to