get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/48992/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 48992,
    "url": "https://patches.dpdk.org/api/patches/48992/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/1545032259-77179-22-git-send-email-wenzhuo.lu@intel.com/",
    "project": {
        "id": 1,
        "url": "https://patches.dpdk.org/api/projects/1/?format=api",
        "name": "DPDK",
        "link_name": "dpdk",
        "list_id": "dev.dpdk.org",
        "list_email": "dev@dpdk.org",
        "web_url": "http://core.dpdk.org",
        "scm_url": "git://dpdk.org/dpdk",
        "webscm_url": "http://git.dpdk.org/dpdk",
        "list_archive_url": "https://inbox.dpdk.org/dev",
        "list_archive_url_format": "https://inbox.dpdk.org/dev/{}",
        "commit_url_format": ""
    },
    "msgid": "<1545032259-77179-22-git-send-email-wenzhuo.lu@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1545032259-77179-22-git-send-email-wenzhuo.lu@intel.com",
    "date": "2018-12-17T07:37:29",
    "name": "[v5,21/31] net/ice: support MAC ops",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "410620466c1c30eab274a3a139075bda9ce55c5a",
    "submitter": {
        "id": 258,
        "url": "https://patches.dpdk.org/api/people/258/?format=api",
        "name": "Wenzhuo Lu",
        "email": "wenzhuo.lu@intel.com"
    },
    "delegate": {
        "id": 1540,
        "url": "https://patches.dpdk.org/api/users/1540/?format=api",
        "username": "qzhan15",
        "first_name": "Qi",
        "last_name": "Zhang",
        "email": "qi.z.zhang@intel.com"
    },
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/1545032259-77179-22-git-send-email-wenzhuo.lu@intel.com/mbox/",
    "series": [
        {
            "id": 2824,
            "url": "https://patches.dpdk.org/api/series/2824/?format=api",
            "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=2824",
            "date": "2018-12-17T07:37:08",
            "name": "A new net PMD - ICE",
            "version": 5,
            "mbox": "https://patches.dpdk.org/series/2824/mbox/"
        }
    ],
    "comments": "https://patches.dpdk.org/api/patches/48992/comments/",
    "check": "warning",
    "checks": "https://patches.dpdk.org/api/patches/48992/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@dpdk.org",
        "Delivered-To": "patchwork@dpdk.org",
        "Received": [
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 7A4FF1BA59;\n\tMon, 17 Dec 2018 08:33:34 +0100 (CET)",
            "from mga09.intel.com (mga09.intel.com [134.134.136.24])\n\tby dpdk.org (Postfix) with ESMTP id B38891B8B5\n\tfor <dev@dpdk.org>; Mon, 17 Dec 2018 08:33:20 +0100 (CET)",
            "from orsmga002.jf.intel.com ([10.7.209.21])\n\tby orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t16 Dec 2018 23:33:19 -0800",
            "from dpdk26.sh.intel.com ([10.67.110.164])\n\tby orsmga002.jf.intel.com with ESMTP; 16 Dec 2018 23:33:19 -0800"
        ],
        "X-Amp-Result": "SKIPPED(no attachment in message)",
        "X-Amp-File-Uploaded": "False",
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.56,364,1539673200\"; d=\"scan'208\";a=\"118899294\"",
        "From": "Wenzhuo Lu <wenzhuo.lu@intel.com>",
        "To": "dev@dpdk.org",
        "Cc": "Wenzhuo Lu <wenzhuo.lu@intel.com>, Qiming Yang <qiming.yang@intel.com>, \n\tXiaoyun Li <xiaoyun.li@intel.com>, Jingjing Wu <jingjing.wu@intel.com>",
        "Date": "Mon, 17 Dec 2018 15:37:29 +0800",
        "Message-Id": "<1545032259-77179-22-git-send-email-wenzhuo.lu@intel.com>",
        "X-Mailer": "git-send-email 1.9.3",
        "In-Reply-To": "<1545032259-77179-1-git-send-email-wenzhuo.lu@intel.com>",
        "References": "<1542956179-80951-1-git-send-email-wenzhuo.lu@intel.com>\n\t<1545032259-77179-1-git-send-email-wenzhuo.lu@intel.com>",
        "Subject": "[dpdk-dev] [PATCH v5 21/31] net/ice: support MAC ops",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.15",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Archive": "<http://mails.dpdk.org/archives/dev/>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "Add below ops,\nmac_addr_set\nmac_addr_add\nmac_addr_remove\n\nSigned-off-by: Wenzhuo Lu <wenzhuo.lu@intel.com>\nSigned-off-by: Qiming Yang <qiming.yang@intel.com>\nSigned-off-by: Xiaoyun Li <xiaoyun.li@intel.com>\nSigned-off-by: Jingjing Wu <jingjing.wu@intel.com>\n---\n doc/guides/nics/features/ice.ini |   2 +\n drivers/net/ice/ice_ethdev.c     | 236 +++++++++++++++++++++++++++++++++++++++\n 2 files changed, 238 insertions(+)",
    "diff": "diff --git a/doc/guides/nics/features/ice.ini b/doc/guides/nics/features/ice.ini\nindex fab6442..759a036 100644\n--- a/doc/guides/nics/features/ice.ini\n+++ b/doc/guides/nics/features/ice.ini\n@@ -10,6 +10,8 @@ Link status event    = Y\n Queue start/stop     = Y\n MTU update           = Y\n Jumbo frame          = Y\n+Unicast MAC filter   = Y\n+Multicast MAC filter = Y\n BSD nic_uio          = Y\n Linux UIO            = Y\n Linux VFIO           = Y\ndiff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c\nindex 0c0efce..29840fd 100644\n--- a/drivers/net/ice/ice_ethdev.c\n+++ b/drivers/net/ice/ice_ethdev.c\n@@ -24,6 +24,13 @@ static void ice_dev_info_get(struct rte_eth_dev *dev,\n static int ice_link_update(struct rte_eth_dev *dev,\n \t\t\t   int wait_to_complete);\n static int ice_mtu_set(struct rte_eth_dev *dev, uint16_t mtu);\n+static int ice_macaddr_set(struct rte_eth_dev *dev,\n+\t\t\t   struct ether_addr *mac_addr);\n+static int ice_macaddr_add(struct rte_eth_dev *dev,\n+\t\t\t   struct ether_addr *mac_addr,\n+\t\t\t   __rte_unused uint32_t index,\n+\t\t\t   uint32_t pool);\n+static void ice_macaddr_remove(struct rte_eth_dev *dev, uint32_t index);\n \n static const struct rte_pci_id pci_id_ice_map[] = {\n \t{ RTE_PCI_DEVICE(ICE_INTEL_VENDOR_ID, ICE_DEV_ID_E810C_BACKPLANE) },\n@@ -50,6 +57,9 @@ static int ice_link_update(struct rte_eth_dev *dev,\n \t.dev_supported_ptypes_get     = ice_dev_supported_ptypes_get,\n \t.link_update                  = ice_link_update,\n \t.mtu_set                      = ice_mtu_set,\n+\t.mac_addr_set                 = ice_macaddr_set,\n+\t.mac_addr_add                 = ice_macaddr_add,\n+\t.mac_addr_remove              = ice_macaddr_remove,\n };\n \n static void\n@@ -336,6 +346,130 @@ static int ice_link_update(struct rte_eth_dev *dev,\n \treturn 0;\n }\n \n+/* Find out specific MAC filter */\n+static struct ice_mac_filter *\n+ice_find_mac_filter(struct ice_vsi *vsi, struct ether_addr *macaddr)\n+{\n+\tstruct ice_mac_filter *f;\n+\n+\tTAILQ_FOREACH(f, &vsi->mac_list, next) {\n+\t\tif (is_same_ether_addr(macaddr, &f->mac_info.mac_addr))\n+\t\t\treturn f;\n+\t}\n+\n+\treturn NULL;\n+}\n+\n+static int\n+ice_add_mac_filter(struct ice_vsi *vsi, struct ether_addr *mac_addr)\n+{\n+\tstruct ice_fltr_list_entry *m_list_itr = NULL;\n+\tstruct ice_mac_filter *f;\n+\tstruct LIST_HEAD_TYPE list_head;\n+\tstruct ice_hw *hw = ICE_VSI_TO_HW(vsi);\n+\tint ret = 0;\n+\n+\t/* If it's added and configured, return */\n+\tf = ice_find_mac_filter(vsi, mac_addr);\n+\tif (f) {\n+\t\tPMD_DRV_LOG(INFO, \"This MAC filter already exists.\");\n+\t\treturn 0;\n+\t}\n+\n+\tINIT_LIST_HEAD(&list_head);\n+\n+\tm_list_itr = (struct ice_fltr_list_entry *)\n+\t\tice_malloc(hw, sizeof(*m_list_itr));\n+\tif (!m_list_itr) {\n+\t\tret = -ENOMEM;\n+\t\tgoto DONE;\n+\t}\n+\tice_memcpy(m_list_itr->fltr_info.l_data.mac.mac_addr,\n+\t\t   mac_addr, ETH_ALEN, ICE_NONDMA_TO_NONDMA);\n+\tm_list_itr->fltr_info.src_id = ICE_SRC_ID_VSI;\n+\tm_list_itr->fltr_info.fltr_act = ICE_FWD_TO_VSI;\n+\tm_list_itr->fltr_info.lkup_type = ICE_SW_LKUP_MAC;\n+\tm_list_itr->fltr_info.flag = ICE_FLTR_TX;\n+\tm_list_itr->fltr_info.vsi_handle = vsi->idx;\n+\n+\tLIST_ADD(&m_list_itr->list_entry, &list_head);\n+\n+\t/* Add the mac */\n+\tret = ice_add_mac(hw, &list_head);\n+\tif (ret != ICE_SUCCESS) {\n+\t\tPMD_DRV_LOG(ERR, \"Failed to add MAC filter\");\n+\t\tret = -EINVAL;\n+\t\tgoto DONE;\n+\t}\n+\t/* Add the mac addr into mac list */\n+\tf = rte_zmalloc(NULL, sizeof(*f), 0);\n+\tif (!f) {\n+\t\tPMD_DRV_LOG(ERR, \"failed to allocate memory\");\n+\t\tret = -ENOMEM;\n+\t\tgoto DONE;\n+\t}\n+\trte_memcpy(&f->mac_info.mac_addr, mac_addr, ETH_ADDR_LEN);\n+\tTAILQ_INSERT_TAIL(&vsi->mac_list, f, next);\n+\tvsi->mac_num++;\n+\n+\tret = 0;\n+\n+DONE:\n+\trte_free(m_list_itr);\n+\treturn ret;\n+}\n+\n+static int\n+ice_remove_mac_filter(struct ice_vsi *vsi, struct ether_addr *mac_addr)\n+{\n+\tstruct ice_fltr_list_entry *m_list_itr = NULL;\n+\tstruct ice_mac_filter *f;\n+\tstruct LIST_HEAD_TYPE list_head;\n+\tstruct ice_hw *hw = ICE_VSI_TO_HW(vsi);\n+\tint ret = 0;\n+\n+\t/* Can't find it, return an error */\n+\tf = ice_find_mac_filter(vsi, mac_addr);\n+\tif (!f)\n+\t\treturn -EINVAL;\n+\n+\tINIT_LIST_HEAD(&list_head);\n+\n+\tm_list_itr = (struct ice_fltr_list_entry *)\n+\t\tice_malloc(hw, sizeof(*m_list_itr));\n+\tif (!m_list_itr) {\n+\t\tret = -ENOMEM;\n+\t\tgoto DONE;\n+\t}\n+\tice_memcpy(m_list_itr->fltr_info.l_data.mac.mac_addr,\n+\t\t   mac_addr, ETH_ALEN, ICE_NONDMA_TO_NONDMA);\n+\tm_list_itr->fltr_info.src_id = ICE_SRC_ID_VSI;\n+\tm_list_itr->fltr_info.fltr_act = ICE_FWD_TO_VSI;\n+\tm_list_itr->fltr_info.lkup_type = ICE_SW_LKUP_MAC;\n+\tm_list_itr->fltr_info.flag = ICE_FLTR_TX;\n+\tm_list_itr->fltr_info.vsi_handle = vsi->idx;\n+\n+\tLIST_ADD(&m_list_itr->list_entry, &list_head);\n+\n+\t/* remove the mac filter */\n+\tret = ice_remove_mac(hw, &list_head);\n+\tif (ret != ICE_SUCCESS) {\n+\t\tPMD_DRV_LOG(ERR, \"Failed to remove MAC filter\");\n+\t\tret = -EINVAL;\n+\t\tgoto DONE;\n+\t}\n+\n+\t/* Remove the mac addr from mac list */\n+\tTAILQ_REMOVE(&vsi->mac_list, f, next);\n+\trte_free(f);\n+\tvsi->mac_num--;\n+\n+\tret = 0;\n+DONE:\n+\trte_free(m_list_itr);\n+\treturn ret;\n+}\n+\n /* Enable IRQ0 */\n static void\n ice_pf_enable_irq0(struct ice_hw *hw)\n@@ -544,6 +678,9 @@ static int ice_link_update(struct rte_eth_dev *dev,\n \tstruct ice_vsi *vsi = NULL;\n \tstruct ice_vsi_ctx vsi_ctx;\n \tint ret;\n+\tstruct ether_addr broadcast = {\n+\t\t.addr_bytes = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff} };\n+\tstruct ether_addr mac_addr;\n \tuint16_t max_txqs[ICE_MAX_TRAFFIC_CLASS] = { 0 };\n \tuint8_t tc_bitmap = 0x1;\n \n@@ -629,6 +766,21 @@ static int ice_link_update(struct rte_eth_dev *dev,\n \tpf->vsis_allocated = vsi_ctx.vsis_allocd;\n \tpf->vsis_unallocated = vsi_ctx.vsis_unallocated;\n \n+\t/* MAC configuration */\n+\trte_memcpy(pf->dev_addr.addr_bytes,\n+\t\t   hw->port_info->mac.perm_addr,\n+\t\t   ETH_ADDR_LEN);\n+\n+\trte_memcpy(&mac_addr, &pf->dev_addr, ETHER_ADDR_LEN);\n+\tret = ice_add_mac_filter(vsi, &mac_addr);\n+\tif (ret != ICE_SUCCESS)\n+\t\tPMD_INIT_LOG(ERR, \"Failed to add dflt MAC filter\");\n+\n+\trte_memcpy(&mac_addr, &broadcast, ETHER_ADDR_LEN);\n+\tret = ice_add_mac_filter(vsi, &mac_addr);\n+\tif (ret != ICE_SUCCESS)\n+\t\tPMD_INIT_LOG(ERR, \"Failed to add MAC filter\");\n+\n \t/* At the beginning, only TC0. */\n \t/* What we need here is the maximam number of the TX queues.\n \t * Currently vsi->nb_qps means it.\n@@ -1261,6 +1413,90 @@ static int ice_init_rss(struct ice_pf *pf)\n \treturn 0;\n }\n \n+static int ice_macaddr_set(struct rte_eth_dev *dev,\n+\t\t\t   struct ether_addr *mac_addr)\n+{\n+\tstruct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);\n+\tstruct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);\n+\tstruct ice_vsi *vsi = pf->main_vsi;\n+\tstruct ice_mac_filter *f;\n+\tuint8_t flags = 0;\n+\tint ret;\n+\n+\tif (!is_valid_assigned_ether_addr(mac_addr)) {\n+\t\tPMD_DRV_LOG(ERR, \"Tried to set invalid MAC address.\");\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tTAILQ_FOREACH(f, &vsi->mac_list, next) {\n+\t\tif (is_same_ether_addr(&pf->dev_addr, &f->mac_info.mac_addr))\n+\t\t\tbreak;\n+\t}\n+\n+\tif (!f) {\n+\t\tPMD_DRV_LOG(ERR, \"Failed to find filter for default mac\");\n+\t\treturn -EIO;\n+\t}\n+\n+\tret = ice_remove_mac_filter(vsi, &f->mac_info.mac_addr);\n+\tif (ret != ICE_SUCCESS) {\n+\t\tPMD_DRV_LOG(ERR, \"Failed to delete mac filter\");\n+\t\treturn -EIO;\n+\t}\n+\tret = ice_add_mac_filter(vsi, mac_addr);\n+\tif (ret != ICE_SUCCESS) {\n+\t\tPMD_DRV_LOG(ERR, \"Failed to add mac filter\");\n+\t\treturn -EIO;\n+\t}\n+\tmemcpy(&pf->dev_addr, mac_addr, ETH_ADDR_LEN);\n+\n+\tflags = ICE_AQC_MAN_MAC_UPDATE_LAA_WOL;\n+\tret = ice_aq_manage_mac_write(hw, mac_addr->addr_bytes, flags, NULL);\n+\tif (ret != ICE_SUCCESS) {\n+\t\tPMD_DRV_LOG(ERR, \"Failed to set manage mac\");\n+\t}\n+\n+\treturn 0;\n+}\n+\n+/* Add a MAC address, and update filters */\n+static int\n+ice_macaddr_add(struct rte_eth_dev *dev,\n+\t\tstruct ether_addr *mac_addr,\n+\t\t__rte_unused uint32_t index,\n+\t\t__rte_unused uint32_t pool)\n+{\n+\tstruct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);\n+\tstruct ice_vsi *vsi = pf->main_vsi;\n+\tint ret;\n+\n+\tret = ice_add_mac_filter(vsi, mac_addr);\n+\tif (ret != ICE_SUCCESS) {\n+\t\tPMD_DRV_LOG(ERR, \"Failed to add MAC filter\");\n+\t\treturn -EINVAL;\n+\t}\n+\n+\treturn ICE_SUCCESS;\n+}\n+\n+/* Remove a MAC address, and update filters */\n+static void\n+ice_macaddr_remove(struct rte_eth_dev *dev, uint32_t index)\n+{\n+\tstruct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);\n+\tstruct ice_vsi *vsi = pf->main_vsi;\n+\tstruct rte_eth_dev_data *data = dev->data;\n+\tstruct ether_addr *macaddr;\n+\tint ret;\n+\n+\tmacaddr = &data->mac_addrs[index];\n+\tret = ice_remove_mac_filter(vsi, macaddr);\n+\tif (ret) {\n+\t\tPMD_DRV_LOG(ERR, \"Failed to remove MAC filter\");\n+\t\treturn;\n+\t}\n+}\n+\n static int\n ice_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,\n \t      struct rte_pci_device *pci_dev)\n",
    "prefixes": [
        "v5",
        "21/31"
    ]
}