[dpdk-dev] [PATCH v3 22/34] net/ice: support MAC ops
Zhang, Qi Z
qi.z.zhang at intel.com
Thu Dec 13 10:00:17 CET 2018
> -----Original Message-----
> From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Wenzhuo Lu
> Sent: Wednesday, December 12, 2018 3:00 PM
> To: dev at dpdk.org
> Cc: Lu, Wenzhuo <wenzhuo.lu at intel.com>; Yang, Qiming
> <qiming.yang at intel.com>; Li, Xiaoyun <xiaoyun.li at intel.com>; Wu, Jingjing
> <jingjing.wu at intel.com>
> 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 <wenzhuo.lu at intel.com>
> Signed-off-by: Qiming Yang <qiming.yang at intel.com>
> Signed-off-by: Xiaoyun Li <xiaoyun.li at intel.com>
> Signed-off-by: Jingjing Wu <jingjing.wu at intel.com>
.....
> ---
> 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;
> +}
> +
More information about the dev
mailing list