RE: [PATCH V3 net-next 3/8] net: hns3: Add HNS3 VF HCL(Hardware Compatibility Layer) Support
Hi Philippe, > -Original Message- > From: Philippe Ombredanne [mailto:pombreda...@nexb.com] > Sent: Wednesday, December 13, 2017 12:54 PM > To: Salil Mehta <salil.me...@huawei.com> > Cc: David S. Miller <da...@davemloft.net>; Zhuangyuzeng (Yisen) > <yisen.zhu...@huawei.com>; lipeng (Y) <lipeng...@huawei.com>; Salil > Mehta <mehta.salil@gmail.com>; netdev@vger.kernel.org; LKML ker...@vger.kernel.org>; linux-r...@vger.kernel.org; Linuxarm > <linux...@huawei.com> > Subject: Re: [PATCH V3 net-next 3/8] net: hns3: Add HNS3 VF > HCL(Hardware Compatibility Layer) Support > > Dear Salil, > > On Wed, Dec 13, 2017 at 11:35 AM, Salil Mehta <salil.me...@huawei.com> > wrote: > > > I could also make out from different articles, including from the > below, > > Linus suggesting moving to "//" type instead of starred ones for > headers. > > > > It looks SPDX change is still a suggestion? > > Well, I think this has been discussed and agreed among maintainers at > the plumbers summit and here on this list. And when I see Thomas doc > patches, Greg patches, other key maintainers as well as Linus comments > and reviews and guidelines, I can can hardly see this as just being a > "suggestion", but that's your call to consider it this way. Ok. I understand. Thanks for confirming it. I will do the changes as suggested by you and thanks for bringing this into notice. Best regards Salil
Re: [PATCH V3 net-next 3/8] net: hns3: Add HNS3 VF HCL(Hardware Compatibility Layer) Support
Dear Salil, On Wed, Dec 13, 2017 at 11:35 AM, Salil Mehtawrote: > I could also make out from different articles, including from the below, > Linus suggesting moving to "//" type instead of starred ones for headers. > > It looks SPDX change is still a suggestion? Well, I think this has been discussed and agreed among maintainers at the plumbers summit and here on this list. And when I see Thomas doc patches, Greg patches, other key maintainers as well as Linus comments and reviews and guidelines, I can can hardly see this as just being a "suggestion", but that's your call to consider it this way. -- Cordially Philippe Ombredanne
RE: [PATCH V3 net-next 3/8] net: hns3: Add HNS3 VF HCL(Hardware Compatibility Layer) Support
Hi Philippe, > -Original Message- > From: Philippe Ombredanne [mailto:pombreda...@nexb.com] > Sent: Tuesday, December 12, 2017 10:41 PM > To: Salil Mehta <salil.me...@huawei.com> > Cc: David S. Miller <da...@davemloft.net>; Zhuangyuzeng (Yisen) > <yisen.zhu...@huawei.com>; lipeng (Y) <lipeng...@huawei.com>; Salil > Mehta <mehta.salil@gmail.com>; netdev@vger.kernel.org; LKML ker...@vger.kernel.org>; linux-r...@vger.kernel.org; Linuxarm > <linux...@huawei.com> > Subject: Re: [PATCH V3 net-next 3/8] net: hns3: Add HNS3 VF > HCL(Hardware Compatibility Layer) Support > > Dear Salil, > > On Tue, Dec 12, 2017 at 6:52 PM, Salil Mehta <salil.me...@huawei.com> > wrote: > > This patch adds the support of hardware compatibiltiy layer to the > > HNS3 VF Driver. This layer implements various {set|get} operations > > over MAC address for a virtual port, RSS related configuration, > > fetches the link status info from PF, does various VLAN related > > configuration over the virtual port, queries the statistics from > > the hardware etc. > > > > This layer can directly interact with hardware through the > > IMP(Integrated Mangement Processor) interface or can use mailbox > > to interact with the PF driver. > > > > Signed-off-by: Salil Mehta <salil.me...@huawei.com> > > Signed-off-by: lipeng <lipeng...@huawei.com> > > --- > > Patch V3: Addressed SPDX change requested by Philippe Ombredanne > > Link: https://lkml.org/lkml/2017/12/8/874 > > Patch V2: Addressed some internal comments > > Patch V1: Initial Submit > > --- > > .../ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c | 1490 > > > .../ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h | 164 +++ > > 2 files changed, 1654 insertions(+) > > create mode 100644 > drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c > > create mode 100644 > drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h > > > > diff --git > a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c > b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c > > new file mode 100644 > > index 000..ff55f4c > > --- /dev/null > > +++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c > > @@ -0,0 +1,1490 @@ > > +// SPDX-License-Identifier: GPL-2.0+ > > +/* > > + * Copyright (c) 2016-2017 Hisilicon Limited. > > + */ > > This is just me nitpicking and this is entirely up to you but in > such a simple case you could go all the way too: > > > +// SPDX-License-Identifier: GPL-2.0+ > > +// Copyright (c) 2016-2017 Hisilicon Limited. > > In this case this can make the thing look more consistent. Ok I can do that, no issues with that. As such, I changed according to Jonathan Corbet's article on LWN. https://lwn.net/Articles/739183/ and also searched the SPDX identifier usage in the existing kernel and I can see community following different ways including (*) For Kernel C files: // SPDX-License-Identifier: GPL-2.0+ // Copyright (c) 2016-2017 Hisilicon Limited. OR // SPDX-License-Identifier: GPL-2.0+ /* * Copyright (c) 2016-2017 Hisilicon Limited. */ OR // SPDX-License-Identifier: GPL-2.0+ (*) For Kernel h files: /* SPDX-License-Identifier: GPL-2.0+ */ /* Copyright (c) 2016-2017 Hisilicon Limited. */ (*) For Makefiles # SPDX-License-Identifier: GPL-2.0+ OR # id: Makefile # SPDX-License-Identifier: GPL-2.0+ I could also make out from different articles, including from the below, Linus suggesting moving to "//" type instead of starred ones for headers. It looks SPDX change is still a suggestion? > See also Linus commentaries about this [1][2][3][4] > > [1] https://lkml.org/lkml/2017/11/25/133 > [2] https://lkml.org/lkml/2017/11/25/125 > [3] https://lkml.org/lkml/2017/11/2/715 > [4] https://lkml.org/lkml/2017/11/2/805 Sure, thanks. Salil
Re: [PATCH V3 net-next 3/8] net: hns3: Add HNS3 VF HCL(Hardware Compatibility Layer) Support
Dear Salil, On Tue, Dec 12, 2017 at 6:52 PM, Salil Mehtawrote: > This patch adds the support of hardware compatibiltiy layer to the > HNS3 VF Driver. This layer implements various {set|get} operations > over MAC address for a virtual port, RSS related configuration, > fetches the link status info from PF, does various VLAN related > configuration over the virtual port, queries the statistics from > the hardware etc. > > This layer can directly interact with hardware through the > IMP(Integrated Mangement Processor) interface or can use mailbox > to interact with the PF driver. > > Signed-off-by: Salil Mehta > Signed-off-by: lipeng > --- > Patch V3: Addressed SPDX change requested by Philippe Ombredanne > Link: https://lkml.org/lkml/2017/12/8/874 > Patch V2: Addressed some internal comments > Patch V1: Initial Submit > --- > .../ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c | 1490 > > .../ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h | 164 +++ > 2 files changed, 1654 insertions(+) > create mode 100644 drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c > create mode 100644 drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h > > diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c > b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c > new file mode 100644 > index 000..ff55f4c > --- /dev/null > +++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c > @@ -0,0 +1,1490 @@ > +// SPDX-License-Identifier: GPL-2.0+ > +/* > + * Copyright (c) 2016-2017 Hisilicon Limited. > + */ This is just me nitpicking and this is entirely up to you but in such a simple case you could go all the way too: > +// SPDX-License-Identifier: GPL-2.0+ > +// Copyright (c) 2016-2017 Hisilicon Limited. In this case this can make the thing look more consistent. See also Linus commentaries about this [1][2][3][4] [1] https://lkml.org/lkml/2017/11/25/133 [2] https://lkml.org/lkml/2017/11/25/125 [3] https://lkml.org/lkml/2017/11/2/715 [4] https://lkml.org/lkml/2017/11/2/805 -- Cordially Philippe Ombredanne
[PATCH V3 net-next 3/8] net: hns3: Add HNS3 VF HCL(Hardware Compatibility Layer) Support
This patch adds the support of hardware compatibiltiy layer to the HNS3 VF Driver. This layer implements various {set|get} operations over MAC address for a virtual port, RSS related configuration, fetches the link status info from PF, does various VLAN related configuration over the virtual port, queries the statistics from the hardware etc. This layer can directly interact with hardware through the IMP(Integrated Mangement Processor) interface or can use mailbox to interact with the PF driver. Signed-off-by: Salil MehtaSigned-off-by: lipeng --- Patch V3: Addressed SPDX change requested by Philippe Ombredanne Link: https://lkml.org/lkml/2017/12/8/874 Patch V2: Addressed some internal comments Patch V1: Initial Submit --- .../ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c | 1490 .../ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h | 164 +++ 2 files changed, 1654 insertions(+) create mode 100644 drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c create mode 100644 drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c new file mode 100644 index 000..ff55f4c --- /dev/null +++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c @@ -0,0 +1,1490 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (c) 2016-2017 Hisilicon Limited. + */ + +#include +#include "hclgevf_cmd.h" +#include "hclgevf_main.h" +#include "hclge_mbx.h" +#include "hnae3.h" + +#define HCLGEVF_NAME "hclgevf" + +static struct hnae3_ae_algo ae_algovf; + +static const struct pci_device_id ae_algovf_pci_tbl[] = { + {PCI_VDEVICE(HUAWEI, HNAE3_DEV_ID_100G_VF), 0}, + {PCI_VDEVICE(HUAWEI, HNAE3_DEV_ID_100G_RDMA_DCB_PFC_VF), 0}, + /* required last entry */ + {0, } +}; + +static inline struct hclgevf_dev *hclgevf_ae_get_hdev( + struct hnae3_handle *handle) +{ + return container_of(handle, struct hclgevf_dev, nic); +} + +static int hclgevf_tqps_update_stats(struct hnae3_handle *handle) +{ + struct hclgevf_dev *hdev = hclgevf_ae_get_hdev(handle); + struct hnae3_queue *queue; + struct hclgevf_desc desc; + struct hclgevf_tqp *tqp; + int status; + int i; + + for (i = 0; i < hdev->num_tqps; i++) { + queue = handle->kinfo.tqp[i]; + tqp = container_of(queue, struct hclgevf_tqp, q); + hclgevf_cmd_setup_basic_desc(, +HCLGEVF_OPC_QUERY_RX_STATUS, +true); + + desc.data[0] = cpu_to_le32(tqp->index & 0x1ff); + status = hclgevf_cmd_send(>hw, , 1); + if (status) { + dev_err(>pdev->dev, + "Query tqp stat fail, status = %d,queue = %d\n", + status, i); + return status; + } + tqp->tqp_stats.rcb_rx_ring_pktnum_rcd += + le32_to_cpu(desc.data[4]); + + hclgevf_cmd_setup_basic_desc(, HCLGEVF_OPC_QUERY_TX_STATUS, +true); + + desc.data[0] = cpu_to_le32(tqp->index & 0x1ff); + status = hclgevf_cmd_send(>hw, , 1); + if (status) { + dev_err(>pdev->dev, + "Query tqp stat fail, status = %d,queue = %d\n", + status, i); + return status; + } + tqp->tqp_stats.rcb_tx_ring_pktnum_rcd += + le32_to_cpu(desc.data[4]); + } + + return 0; +} + +static u64 *hclgevf_tqps_get_stats(struct hnae3_handle *handle, u64 *data) +{ + struct hnae3_knic_private_info *kinfo = >kinfo; + struct hclgevf_dev *hdev = hclgevf_ae_get_hdev(handle); + struct hclgevf_tqp *tqp; + u64 *buff = data; + int i; + + for (i = 0; i < hdev->num_tqps; i++) { + tqp = container_of(handle->kinfo.tqp[i], struct hclgevf_tqp, q); + *buff++ = tqp->tqp_stats.rcb_tx_ring_pktnum_rcd; + } + for (i = 0; i < kinfo->num_tqps; i++) { + tqp = container_of(handle->kinfo.tqp[i], struct hclgevf_tqp, q); + *buff++ = tqp->tqp_stats.rcb_rx_ring_pktnum_rcd; + } + + return buff; +} + +static int hclgevf_tqps_get_sset_count(struct hnae3_handle *handle, int strset) +{ + struct hclgevf_dev *hdev = hclgevf_ae_get_hdev(handle); + + return hdev->num_tqps * 2; +} + +static u8 *hclgevf_tqps_get_strings(struct hnae3_handle *handle, u8 *data) +{ + struct hclgevf_dev *hdev = hclgevf_ae_get_hdev(handle); + u8 *buff = data; + int i = 0; + + for (i = 0; i < hdev->num_tqps; i++) { + struct hclgevf_tqp *tqp =