net: ethernet: efct Add x3 ethernet driver
Subsystems (2)
cover net: ethernet: efct Add x3 ethernet driver
This patch series adds new ethernet network driver for Alveo X3522[1]. X3 is a low-latency NIC with an aim to deliver the lowest possible latency. It accelerates a range of diverse trading strategies and financial applications.
Harsh Jain (6):
net: ethernet: efct: New X3 net driver
net: ethernet: efct: Add datapath
net: ethernet: efct: Add devlink support
net: ethernet: efct: Add Hardware timestamp support
net: ethernet: efct: Add ethtool support
net: ethernet: efct: Add maintainer, kconfig, makefile
MAINTAINERS | 7 + drivers/net/ethernet/amd/Kconfig | 2 + drivers/net/ethernet/amd/Makefile | 2 + drivers/net/ethernet/amd/efct/Kconfig | 40 + drivers/net/ethernet/amd/efct/Makefile | 13 + drivers/net/ethernet/amd/efct/efct_bitfield.h | 483 ++ drivers/net/ethernet/amd/efct/efct_common.c | 1314 ++++ drivers/net/ethernet/amd/efct/efct_common.h | 134 + drivers/net/ethernet/amd/efct/efct_devlink.c | 829 +++ drivers/net/ethernet/amd/efct/efct_devlink.h | 21 + drivers/net/ethernet/amd/efct/efct_driver.h | 788 +++ drivers/net/ethernet/amd/efct/efct_enum.h | 130 + drivers/net/ethernet/amd/efct/efct_ethtool.c | 1286 ++++ drivers/net/ethernet/amd/efct/efct_evq.c | 185 + drivers/net/ethernet/amd/efct/efct_evq.h | 21 + drivers/net/ethernet/amd/efct/efct_io.h | 64 + drivers/net/ethernet/amd/efct/efct_netdev.c | 502 ++ drivers/net/ethernet/amd/efct/efct_netdev.h | 19 + drivers/net/ethernet/amd/efct/efct_nic.c | 1558 +++++ drivers/net/ethernet/amd/efct/efct_nic.h | 104 + drivers/net/ethernet/amd/efct/efct_pci.c | 1099 ++++ drivers/net/ethernet/amd/efct/efct_ptp.c | 1481 +++++ drivers/net/ethernet/amd/efct/efct_ptp.h | 186 + drivers/net/ethernet/amd/efct/efct_reflash.c | 564 ++ drivers/net/ethernet/amd/efct/efct_reflash.h | 16 + drivers/net/ethernet/amd/efct/efct_reg.h | 1060 +++ drivers/net/ethernet/amd/efct/efct_rx.c | 591 ++ drivers/net/ethernet/amd/efct/efct_rx.h | 22 + drivers/net/ethernet/amd/efct/efct_tx.c | 330 + drivers/net/ethernet/amd/efct/efct_tx.h | 17 + drivers/net/ethernet/amd/efct/mcdi.c | 1826 ++++++ drivers/net/ethernet/amd/efct/mcdi.h | 373 ++ .../net/ethernet/amd/efct/mcdi_functions.c | 642 ++ .../net/ethernet/amd/efct/mcdi_functions.h | 39 + drivers/net/ethernet/amd/efct/mcdi_pcol.h | 5789 +++++++++++++++++ .../net/ethernet/amd/efct/mcdi_port_common.c | 949 +++ .../net/ethernet/amd/efct/mcdi_port_common.h | 98 + 37 files changed, 22584 insertions(+) create mode 100644 drivers/net/ethernet/amd/efct/Kconfig create mode 100644 drivers/net/ethernet/amd/efct/Makefile create mode 100644 drivers/net/ethernet/amd/efct/efct_bitfield.h create mode 100644 drivers/net/ethernet/amd/efct/efct_common.c create mode 100644 drivers/net/ethernet/amd/efct/efct_common.h create mode 100644 drivers/net/ethernet/amd/efct/efct_devlink.c create mode 100644 drivers/net/ethernet/amd/efct/efct_devlink.h create mode 100644 drivers/net/ethernet/amd/efct/efct_driver.h create mode 100644 drivers/net/ethernet/amd/efct/efct_enum.h create mode 100644 drivers/net/ethernet/amd/efct/efct_ethtool.c create mode 100644 drivers/net/ethernet/amd/efct/efct_evq.c create mode 100644 drivers/net/ethernet/amd/efct/efct_evq.h create mode 100644 drivers/net/ethernet/amd/efct/efct_io.h create mode 100644 drivers/net/ethernet/amd/efct/efct_netdev.c create mode 100644 drivers/net/ethernet/amd/efct/efct_netdev.h create mode 100644 drivers/net/ethernet/amd/efct/efct_nic.c create mode 100644 drivers/net/ethernet/amd/efct/efct_nic.h create mode 100644 drivers/net/ethernet/amd/efct/efct_pci.c create mode 100644 drivers/net/ethernet/amd/efct/efct_ptp.c create mode 100644 drivers/net/ethernet/amd/efct/efct_ptp.h create mode 100644 drivers/net/ethernet/amd/efct/efct_reflash.c create mode 100644 drivers/net/ethernet/amd/efct/efct_reflash.h create mode 100644 drivers/net/ethernet/amd/efct/efct_reg.h create mode 100644 drivers/net/ethernet/amd/efct/efct_rx.c create mode 100644 drivers/net/ethernet/amd/efct/efct_rx.h create mode 100644 drivers/net/ethernet/amd/efct/efct_tx.c create mode 100644 drivers/net/ethernet/amd/efct/efct_tx.h create mode 100644 drivers/net/ethernet/amd/efct/mcdi.c create mode 100644 drivers/net/ethernet/amd/efct/mcdi.h create mode 100644 drivers/net/ethernet/amd/efct/mcdi_functions.c create mode 100644 drivers/net/ethernet/amd/efct/mcdi_functions.h create mode 100644 drivers/net/ethernet/amd/efct/mcdi_pcol.h create mode 100644 drivers/net/ethernet/amd/efct/mcdi_port_common.c create mode 100644 drivers/net/ethernet/amd/efct/mcdi_port_common.h
Signature · 1 line
2.25.1
PATCH 1/6 net: ethernet: efct: New X3 net driver
This patch series adds new ethernet network driver for Alveo X3522[1]. is a low-latency NIC with an aim to deliver the lowest possible latency. It accelerates a range of diverse trading strategies and financial applications.
Device has 2 PCI functions and each function supports 2 port, currently at 10GbE. This patch deals with PCI device probing and netdev creation. It also adds support for Firmware communication APIs used in later patches.
--- drivers/net/ethernet/amd/efct/efct_bitfield.h | 483 ++ drivers/net/ethernet/amd/efct/efct_common.c | 1154 ++++ drivers/net/ethernet/amd/efct/efct_common.h | 134 + drivers/net/ethernet/amd/efct/efct_driver.h | 770 +++ drivers/net/ethernet/amd/efct/efct_enum.h | 130 + drivers/net/ethernet/amd/efct/efct_evq.c | 185 + drivers/net/ethernet/amd/efct/efct_evq.h | 21 + drivers/net/ethernet/amd/efct/efct_io.h | 64 + drivers/net/ethernet/amd/efct/efct_netdev.c | 459 ++ drivers/net/ethernet/amd/efct/efct_netdev.h | 19 + drivers/net/ethernet/amd/efct/efct_nic.c | 1300 ++++ drivers/net/ethernet/amd/efct/efct_nic.h | 104 + drivers/net/ethernet/amd/efct/efct_pci.c | 1077 +++ drivers/net/ethernet/amd/efct/efct_reg.h | 1060 +++ drivers/net/ethernet/amd/efct/mcdi.c | 1817 ++++++ drivers/net/ethernet/amd/efct/mcdi.h | 373 ++ .../net/ethernet/amd/efct/mcdi_functions.c | 642 ++ .../net/ethernet/amd/efct/mcdi_functions.h | 39 + drivers/net/ethernet/amd/efct/mcdi_pcol.h | 5789 +++++++++++++++++ .../net/ethernet/amd/efct/mcdi_port_common.c | 949 +++ .../net/ethernet/amd/efct/mcdi_port_common.h | 98 + 21 files changed, 16667 insertions(+) create mode 100644 drivers/net/ethernet/amd/efct/efct_bitfield.h create mode 100644 drivers/net/ethernet/amd/efct/efct_common.c create mode 100644 drivers/net/ethernet/amd/efct/efct_common.h create mode 100644 drivers/net/ethernet/amd/efct/efct_driver.h create mode 100644 drivers/net/ethernet/amd/efct/efct_enum.h create mode 100644 drivers/net/ethernet/amd/efct/efct_evq.c create mode 100644 drivers/net/ethernet/amd/efct/efct_evq.h create mode 100644 drivers/net/ethernet/amd/efct/efct_io.h create mode 100644 drivers/net/ethernet/amd/efct/efct_netdev.c create mode 100644 drivers/net/ethernet/amd/efct/efct_netdev.h create mode 100644 drivers/net/ethernet/amd/efct/efct_nic.c create mode 100644 drivers/net/ethernet/amd/efct/efct_nic.h create mode 100644 drivers/net/ethernet/amd/efct/efct_pci.c create mode 100644 drivers/net/ethernet/amd/efct/efct_reg.h create mode 100644 drivers/net/ethernet/amd/efct/mcdi.c create mode 100644 drivers/net/ethernet/amd/efct/mcdi.h create mode 100644 drivers/net/ethernet/amd/efct/mcdi_functions.c create mode 100644 drivers/net/ethernet/amd/efct/mcdi_functions.h create mode 100644 drivers/net/ethernet/amd/efct/mcdi_pcol.h create mode 100644 drivers/net/ethernet/amd/efct/mcdi_port_common.c create mode 100644 drivers/net/ethernet/amd/efct/mcdi_port_common.h
drivers/net/ethernet/amd/efct/efct_bitfield.h new file +483 -0
@@ -0,0 +1,483 @@ +/* SPDX-License-Identifier: GPL-2.0 +**************************************************************************** +* Driver for AMD/Xilinx network controllers and boards +* Copyright (C) 2021, Xilinx, Inc. +* Copyright (C) 2022-2023, Advanced Micro Devices, Inc. +*/ + +#ifndef EFCT_BITFIELD_H +#define EFCT_BITFIELD_H +#include <linux/types.h> + +/* Efct bitfield access +* NIC uses bitfield of upto 128 bits wide. Since there is no +* native 128-bit datatype on most systems, and 64-bit datatypes +* are inefficient on 32-bit systems and vice versa, +* we wrap accesses in a way that uses the most efficient +* datatype. +* +* The NICs are PCI devices and therefore little-endian. Since most +* of the quantities that we deal with are DMAed to/from host memory, +* we define our datatypes (union efct_oword, union efct_dword and +* union efct_qword) to be little-endian. +*/ + +/* Lowest bit numbers and widths */ +#define EFCT_DUMMY_FIELD_LBN 0 +#define EFCT_DUMMY_FIELD_WIDTH 0 +#define EFCT_WORD_0_LBN 0 +#define EFCT_WORD_0_WIDTH 16 +#define EFCT_WORD_1_LBN 16 +#define EFCT_WORD_1_WIDTH 16 +#define EFCT_DWORD_0_LBN 0 +#define EFCT_DWORD_0_WIDTH 32 +#define EFCT_DWORD_1_LBN 32 +#define EFCT_DWORD_1_WIDTH 32 +#define EFCT_DWORD_2_LBN 64 +#define EFCT_DWORD_2_WIDTH 32 +#define EFCT_DWORD_3_LBN 96 +#define EFCT_DWORD_3_WIDTH 32 +#define EFCT_QWORD_0_LBN 0 +#define EFCT_QWORD_0_WIDTH 64 +/* Specified attribute (e.g. LBN) of the specified field */ +#define EFCT_VAL (field, attribute) field ## _ ## attribute +/* Low bit number of the specified field */ +#define EFCT_LOW_BIT (field) EFCT_VAL(field, LBN) +/* Bit width of the specified field */ +#define EFCT_WIDTH (field) EFCT_VAL(field, WIDTH) +/* High bit number of the specified field */ +#define EFCT_HIGH_BIT (field) (EFCT_LOW_BIT(field) + EFCT_WIDTH(field) - 1) +/* Mask equal in width to the specified field. +* +* For example, a field with width 5 would have a mask of 0x1f. +* +* The maximum width mask that can be generated is 64 bits. +*/ +#define EFCT_MASK64 (width) \ + ((width) == 64 ? ~((u64)0) : \ + (((((u64)1) << (width))) - 1)) + +/* Mask equal in width to the specified field. +* +* For example, a field with width 5 would have a mask of 0x1f. +* +* The maximum width mask that can be generated is 32 bits. Use +* EFCT_MASK64 for higher width fields. +*/ +#define EFCT_MASK32 (width) \ + ((width) == 32 ? ~((u32)0) : \ + (((((u32)1) << (width))) - 1)) + +/* A doubleword (i.e. 4 byte) datatype - little-endian in HW */ +union efct_dword { +__le32 word32; +}; + +/* A quadword (i.e. 8 byte) datatype - little-endian in HW */ +union efct_qword { +__le64 u64[1 ]; +__le32 u32[2 ]; +union efct_dword dword[2 ]; +}; + +/* An octword (eight-word, i.e. 16 byte) datatype - little-endian in HW */ +union efct_oword { +__le64 u64[2 ]; +union efct_qword qword[2 ]; +__le32 u32[4 ]; +union efct_dword dword[4 ]; +}; + +/* Format string and value expanders for printk */ +#define EFCT_DWORD_FMT "%08x" +#define EFCT_OWORD_FMT "%08x:%08x:%08x:%08x" +#define EFCT_DWORD_VAL (dword) \ + ((u32)le32_to_cpu((dword).word32)) + +/* Extract bit field portion [low,high) from the native-endian element +* which contains bits [min,max). +* For example, suppose "element" represents the high 32 bits of a +* 64-bit value, and we wish to extract the bits belonging to the bit +* field occupying bits 28-45 of this 64-bit value. +* Then EFCT_EXTRACT ( element, 32, 63, 28, 45 ) would give +* +* ( element ) << 4 +* The result will contain the relevant bits filled in the range +* [0,high-low), with garbage in bits [high-low+1,...). +*/ +#define EFCT_EXTRACT_NATIVE (native_element, min, max, low, high) \ + ((low) > (max) || (high) < (min) ? 0 : \ + (low) > (min) ? \ + (native_element) >> ((low) - (min)) : \ + (native_element) << ((min) - (low))) + +/* Extract bit field portion [low,high) from the 64-bit little-endian +* element which contains bits [min,max) +*/ +#define EFCT_EXTRACT64 (element, min, max, low, high) \ + EFCT_EXTRACT_NATIVE(le64_to_cpu(element), min, max, low, high) + +/* Extract bit field portion [low,high) from the 32-bit little-endian +* element which contains bits [min,max) +*/ +#define EFCT_EXTRACT32 (element, min, max, low, high) \ + EFCT_EXTRACT_NATIVE(le32_to_cpu(element), min, max, low, high) + +#define EFCT_EXTRACT_OWORD64 (oword, low, high) \ + ((EFCT_EXTRACT64((oword).u64[0], 0, 63, low, high) | \ + EFCT_EXTRACT64((oword).u64[1], 64, 127, low, high)) & \ + EFCT_MASK64((high) + 1 - (low))) + +#define EFCT_EXTRACT_QWORD64 (qword, low, high) \ + (EFCT_EXTRACT64((qword).u64[0], 0, 63, low, high) & \ + EFCT_MASK64((high) + 1 - (low))) + +#define EFCT_EXTRACT_OWORD32 (oword, low, high) \ + ((EFCT_EXTRACT32((oword).u32[0], 0, 31, low, high) | \ + EFCT_EXTRACT32((oword).u32[1], 32, 63, low, high) | \ + EFCT_EXTRACT32((oword).u32[2], 64, 95, low, high) | \ + EFCT_EXTRACT32((oword).u32[3], 96, 127, low, high)) & \ + EFCT_MASK32((high) + 1 - (low))) + +#define EFCT_EXTRACT_QWORD32 (qword, low, high) \ + ((EFCT_EXTRACT32((qword).u32[0], 0, 31, low, high) | \ + EFCT_EXTRACT32((qword).u32[1], 32, 63, low, high)) & \ + EFCT_MASK32((high) + 1 - (low))) + +#define EFCT_EXTRACT_DWORD (dword, low, high) \ + (EFCT_EXTRACT32((dword).word32, 0, 31, low, high) & \ + EFCT_MASK32((high) + 1 - (low))) + +#define EFCT_OWORD_FIELD64 (oword, field) \ + EFCT_EXTRACT_OWORD64(oword, EFCT_LOW_BIT(field), \ + EFCT_HIGH_BIT(field)) + +#define EFCT_QWORD_FIELD64 (qword, field) \ + EFCT_EXTRACT_QWORD64(qword, EFCT_LOW_BIT(field), \ + EFCT_HIGH_BIT(field)) + +#define EFCT_OWORD_FIELD32 (oword, field) \ + EFCT_EXTRACT_OWORD32(oword, EFCT_LOW_BIT(field), \ + EFCT_HIGH_BIT(field)) + +#define EFCT_QWORD_FIELD32 (qword, field) \ + EFCT_EXTRACT_QWORD32(qword, EFCT_LOW_BIT(field), \ + EFCT_HIGH_BIT(field)) + +#define EFCT_DWORD_FIELD (dword, field) \ + EFCT_EXTRACT_DWORD(dword, EFCT_LOW_BIT(field), \ + EFCT_HIGH_BIT(field)) + +#define EFCT_OWORD_IS_ZERO64 (oword) \ + (((oword).u64[0] | (oword).u64[1]) == (__force __le64)0) + +#define EFCT_QWORD_IS_ZERO64 (qword) \ + (((qword).u64[0]) == (__force __le64)0) + +#define EFCT_OWORD_IS_ZERO32 (oword) \ + (((oword).u32[0] | (oword).u32[1] | (oword).u32[2] | (oword).u32[3]) \ + == (__force __le32)0) + +#define EFCT_QWORD_IS_ZERO32 (qword) \ + (((qword).u32[0] | (qword).u32[1]) == (__force __le32)0) + +#define EFCT_DWORD_IS_ZERO (dword) \ + (((dword).u32[0]) == (__force __le32)0) + +#define EFCT_OWORD_IS_ALL_ONES64 (oword) \ + (((oword).u64[0] & (oword).u64[1]) == ~((__force __le64)0)) + +#define EFCT_QWORD_IS_ALL_ONES64 (qword) \ + ((qword).u64[0] == ~((__force __le64)0)) + +#define EFCT_OWORD_IS_ALL_ONES32 (oword) \ + (((oword).u32[0] & (oword).u32[1] & (oword).u32[2] & (oword).u32[3]) \ + == ~((__force __le32)0)) + +#define EFCT_QWORD_IS_ALL_ONES32 (qword) \ + (((qword).u32[0] & (qword).u32[1]) == ~((__force __le32)0)) + +#define EFCT_DWORD_IS_ALL_ONES (dword) \ + ((dword).u32[0] == ~((__force __le32)0)) + +#if BITS_PER_LONG ==64 +#define EFCT_OWORD_FIELD EFCT_OWORD_FIELD64 +#define EFCT_QWORD_FIELD EFCT_QWORD_FIELD64 +#define EFCT_OWORD_IS_ZERO EFCT_OWORD_IS_ZERO64 +#define EFCT_QWORD_IS_ZERO EFCT_QWORD_IS_ZERO64 +#define EFCT_OWORD_IS_ALL_ONES EFCT_OWORD_IS_ALL_ONES64 +#define EFCT_QWORD_IS_ALL_ONES EFCT_QWORD_IS_ALL_ONES64 +#else +#define EFCT_OWORD_FIELD EFCT_OWORD_FIELD32 +#define EFCT_QWORD_FIELD EFCT_QWORD_FIELD32 +#define EFCT_OWORD_IS_ZERO EFCT_OWORD_IS_ZERO32 +#define EFCT_QWORD_IS_ZERO EFCT_QWORD_IS_ZERO32 +#define EFCT_OWORD_IS_ALL_ONES EFCT_OWORD_IS_ALL_ONES32 +#define EFCT_QWORD_IS_ALL_ONES EFCT_QWORD_IS_ALL_ONES32 +#endif + +/* Construct bit field portion +* Creates the portion of the bit field [low,high) that lies within +* the range [min,max). +*/ +#define EFCT_INSERT_NATIVE64 (min, max, low, high, value) \ + ((((low) > (max)) || ((high) < (min))) ? 0 : \ + (((low) > (min)) ? \ + (((u64)(value)) << ((low) - (min))) : \ + (((u64)(value)) >> ((min) - (low))))) + +#define EFCT_INSERT_NATIVE32 (min, max, low, high, value) \ + ((((low) > (max)) || ((high) < (min))) ? 0 : \ + (((low) > (min)) ? \ + (((u32)(value)) << ((low) - (min))) : \ + (((u32)(value)) >> ((min) - (low))))) + +#define EFCT_INSERT_NATIVE (min, max, low, high, value) \ + (((((max) - (min)) >= 32) || (((high) - (low)) >= 32)) ? \ + EFCT_INSERT_NATIVE64(min, max, low, high, value) : \ + EFCT_INSERT_NATIVE32(min, max, low, high, value)) + +/* Construct bit field portion +* Creates the portion of the named bit field that lies within the +* range [min,max). +*/ +#define EFCT_INSERT_FIELD_NATIVE (min, max, field, value) \ + EFCT_INSERT_NATIVE(min, max, EFCT_LOW_BIT(field), \ + EFCT_HIGH_BIT(field), value) + +/* Construct bit field +* Creates the portion of the named bit fields that lie within the +* range [min,max). +*/ +#define EFCT_INSERT_FIELDS_NATIVE (_min, _max, \ + field1, value1, \ + field2, value2, \ + field3, value3, \ + field4, value4, \ + field5, value5, \ + field6, value6, \ + field7, value7, \ + field8, value8, \ + field9, value9, \ + field10, value10) \ + ({typeof(_min) (min) = (_min); \ + typeof(_max) (max) = (_max); \ + EFCT_INSERT_FIELD_NATIVE((min), (max), field1, (value1)) | \ + EFCT_INSERT_FIELD_NATIVE((min), (max), field2, (value2)) | \ + EFCT_INSERT_FIELD_NATIVE((min), (max), field3, (value3)) | \ + EFCT_INSERT_FIELD_NATIVE((min), (max), field4, (value4)) | \ + EFCT_INSERT_FIELD_NATIVE((min), (max), field5, (value5)) | \ + EFCT_INSERT_FIELD_NATIVE((min), (max), field6, (value6)) | \ + EFCT_INSERT_FIELD_NATIVE((min), (max), field7, (value7)) | \ + EFCT_INSERT_FIELD_NATIVE((min), (max), field8, (value8)) | \ + EFCT_INSERT_FIELD_NATIVE((min), (max), field9, (value9)) | \ + EFCT_INSERT_FIELD_NATIVE((min), (max), field10, (value10)); }) + +#define EFCT_INSERT_FIELDS64 (...) \ + cpu_to_le64(EFCT_INSERT_FIELDS_NATIVE(__VA_ARGS__)) + +#define EFCT_INSERT_FIELDS32 (...) \ + cpu_to_le32(EFCT_INSERT_FIELDS_NATIVE(__VA_ARGS__)) + +#define EFCT_POPULATE_OWORD64 (oword, ...) do { \ + (oword).u64[0] = EFCT_INSERT_FIELDS64(0, 63, __VA_ARGS__); \ + (oword).u64[1] = EFCT_INSERT_FIELDS64(64, 127, __VA_ARGS__); \ + } while (0) + +#define EFCT_POPULATE_QWORD64 (qword, ...) (qword).u64[0] = EFCT_INSERT_FIELDS64(0, 63, __VA_ARGS__) + +#define EFCT_POPULATE_OWORD32 (oword, ...) do { \ + (oword).u32[0] = EFCT_INSERT_FIELDS32(0, 31, __VA_ARGS__); \ + (oword).u32[1] = EFCT_INSERT_FIELDS32(32, 63, __VA_ARGS__); \ + (oword).u32[2] = EFCT_INSERT_FIELDS32(64, 95, __VA_ARGS__); \ + (oword).u32[3] = EFCT_INSERT_FIELDS32(96, 127, __VA_ARGS__); \ + } while (0) + +#define EFCT_POPULATE_QWORD32 (qword, ...) do { \ + (qword).u32[0] = EFCT_INSERT_FIELDS32(0, 31, __VA_ARGS__); \ + (qword).u32[1] = EFCT_INSERT_FIELDS32(32, 63, __VA_ARGS__); \ + } while (0) + +#define EFCT_POPULATE_DWORD (dword, ...) (dword).word32 = EFCT_INSERT_FIELDS32(0, 31, __VA_ARGS__) + +#if BITS_PER_LONG ==64 +#define EFCT_POPULATE_OWORD EFCT_POPULATE_OWORD64 +#define EFCT_POPULATE_QWORD EFCT_POPULATE_QWORD64 +#else +#define EFCT_POPULATE_OWORD EFCT_POPULATE_OWORD32 +#define EFCT_POPULATE_QWORD EFCT_POPULATE_QWORD32 +#endif + +/* Populate an octword field with various numbers of arguments */ +#define EFCT_POPULATE_OWORD_10 EFCT_POPULATE_OWORD +#define EFCT_POPULATE_OWORD_9 (oword, ...) \ + EFCT_POPULATE_OWORD_10(oword, EFCT_DUMMY_FIELD, 0, __VA_ARGS__) +#define EFCT_POPULATE_OWORD_8 (oword, ...) \ + EFCT_POPULATE_OWORD_9(oword, EFCT_DUMMY_FIELD, 0, __VA_ARGS__) +#define EFCT_POPULATE_OWORD_7 (oword, ...) \ + EFCT_POPULATE_OWORD_8(oword, EFCT_DUMMY_FIELD, 0, __VA_ARGS__) +#define EFCT_POPULATE_OWORD_6 (oword, ...) \ + EFCT_POPULATE_OWORD_7(oword, EFCT_DUMMY_FIELD, 0, __VA_ARGS__) +#define EFCT_POPULATE_OWORD_5 (oword, ...) \ + EFCT_POPULATE_OWORD_6(oword, EFCT_DUMMY_FIELD, 0, __VA_ARGS__) +#define EFCT_POPULATE_OWORD_4 (oword, ...) \ + EFCT_POPULATE_OWORD_5(oword, EFCT_DUMMY_FIELD, 0, __VA_ARGS__) +#define EFCT_POPULATE_OWORD_3 (oword, ...) \ + EFCT_POPULATE_OWORD_4(oword, EFCT_DUMMY_FIELD, 0, __VA_ARGS__) +#define EFCT_POPULATE_OWORD_2 (oword, ...) \ + EFCT_POPULATE_OWORD_3(oword, EFCT_DUMMY_FIELD, 0, __VA_ARGS__) +#define EFCT_POPULATE_OWORD_1 (oword, ...) \ + EFCT_POPULATE_OWORD_2(oword, EFCT_DUMMY_FIELD, 0, __VA_ARGS__) +#define EFCT_ZERO_OWORD (oword) \ + EFCT_POPULATE_OWORD_1(oword, EFCT_DUMMY_FIELD, 0) +#define EFCT_SET_OWORD (oword) \ + EFCT_POPULATE_OWORD_4(oword, \ + EFCT_DWORD_0, 0xffffffff, \ + EFCT_DWORD_1, 0xffffffff, \ + EFCT_DWORD_2, 0xffffffff, \ + EFCT_DWORD_3, 0xffffffff) + +/* Populate a quadword field with various numbers of arguments */ +#define EFCT_POPULATE_QWORD_10 EFCT_POPULATE_QWORD +#define EFCT_POPULATE_QWORD_9 (qword, ...) \ + EFCT_POPULATE_QWORD_10(qword, EFCT_DUMMY_FIELD, 0, __VA_ARGS__) +#define EFCT_POPULATE_QWORD_8 (qword, ...) \ + EFCT_POPULATE_QWORD_9(qword, EFCT_DUMMY_FIELD, 0, __VA_ARGS__) +#define EFCT_POPULATE_QWORD_7 (qword, ...) \ + EFCT_POPULATE_QWORD_8(qword, EFCT_DUMMY_FIELD, 0, __VA_ARGS__) +#define EFCT_POPULATE_QWORD_6 (qword, ...) \ + EFCT_POPULATE_QWORD_7(qword, EFCT_DUMMY_FIELD, 0, __VA_ARGS__) +#define EFCT_POPULATE_QWORD_5 (qword, ...) \ + EFCT_POPULATE_QWORD_6(qword, EFCT_DUMMY_FIELD, 0, __VA_ARGS__) +#define EFCT_POPULATE_QWORD_4 (qword, ...) \ + EFCT_POPULATE_QWORD_5(qword, EFCT_DUMMY_FIELD, 0, __VA_ARGS__) +#define EFCT_POPULATE_QWORD_3 (qword, ...) \ + EFCT_POPULATE_QWORD_4(qword, EFCT_DUMMY_FIELD, 0, __VA_ARGS__) +#define EFCT_POPULATE_QWORD_2 (qword, ...) \ + EFCT_POPULATE_QWORD_3(qword, EFCT_DUMMY_FIELD, 0, __VA_ARGS__) +#define EFCT_POPULATE_QWORD_1 (qword, ...) \ + EFCT_POPULATE_QWORD_2(qword, EFCT_DUMMY_FIELD, 0, __VA_ARGS__) +#define EFCT_ZERO_QWORD (qword) \ + EFCT_POPULATE_QWORD_1(qword, EFCT_DUMMY_FIELD, 0) +#define EFCT_SET_QWORD (qword) \ + EFCT_POPULATE_QWORD_2(qword, \ + EFCT_DWORD_0, 0xffffffff, \ + EFCT_DWORD_1, 0xffffffff) +/* Populate a dword field with various numbers of arguments */ +#define EFCT_POPULATE_DWORD_10 EFCT_POPULATE_DWORD +#define EFCT_POPULATE_DWORD_9 (dword, ...) \ + EFCT_POPULATE_DWORD_10(dword, EFCT_DUMMY_FIELD, 0, __VA_ARGS__) +#define EFCT_POPULATE_DWORD_8 (dword, ...) \ + EFCT_POPULATE_DWORD_9(dword, EFCT_DUMMY_FIELD, 0, __VA_ARGS__) +#define EFCT_POPULATE_DWORD_7 (dword, ...) \ + EFCT_POPULATE_DWORD_8(dword, EFCT_DUMMY_FIELD, 0, __VA_ARGS__) +#define EFCT_POPULATE_DWORD_6 (dword, ...) \ + EFCT_POPULATE_DWORD_7(dword, EFCT_DUMMY_FIELD, 0, __VA_ARGS__) +#define EFCT_POPULATE_DWORD_5 (dword, ...) \ + EFCT_POPULATE_DWORD_6(dword, EFCT_DUMMY_FIELD, 0, __VA_ARGS__) +#define EFCT_POPULATE_DWORD_4 (dword, ...) \ + EFCT_POPULATE_DWORD_5(dword, EFCT_DUMMY_FIELD, 0, __VA_ARGS__) +#define EFCT_POPULATE_DWORD_3 (dword, ...) \ + EFCT_POPULATE_DWORD_4(dword, EFCT_DUMMY_FIELD, 0, __VA_ARGS__) +#define EFCT_POPULATE_DWORD_2 (dword, ...) \ + EFCT_POPULATE_DWORD_3(dword, EFCT_DUMMY_FIELD, 0, __VA_ARGS__) +#define EFCT_POPULATE_DWORD_1 (dword, ...) \ + EFCT_POPULATE_DWORD_2(dword, EFCT_DUMMY_FIELD, 0, __VA_ARGS__) +#define EFCT_ZERO_DWORD (dword) \ + EFCT_POPULATE_DWORD_1(dword, EFCT_DUMMY_FIELD, 0) +#define EFCT_SET_DWORD (dword) \ + EFCT_POPULATE_DWORD_1(dword, EFCT_DWORD_0, 0xffffffff) + +/* Modify a named field within an already-populated structure. Used +* for read-modify-write operations. +*/ + +#define EFCT_INSERT64 (min, max, low, high, value) \ + cpu_to_le64(EFCT_INSERT_NATIVE(min, max, low, high, value)) + +#define EFCT_INSERT32 (min, max, low, high, value) \ + cpu_to_le32(EFCT_INSERT_NATIVE(min, max, low, high, value)) + +#define EFCT_INPLACE_MASK64 (min, max, low, high) \ + EFCT_INSERT64(min, max, low, high, EFCT_MASK64((high) + 1 - (low))) + +#define EFCT_INPLACE_MASK32 (min, max, low, high) \ + EFCT_INSERT32(min, max, low, high, EFCT_MASK32((high) + 1 - (low))) + +#define EFCT_SET_OWORD64 (oword, low, high, value) do { \ + (oword).u64[0] = (((oword).u64[0] \ + & ~EFCT_INPLACE_MASK64(0, 63, low, high)) \ + | EFCT_INSERT64(0, 63, low, high, value)); \ + (oword).u64[1] = (((oword).u64[1] \ + & ~EFCT_INPLACE_MASK64(64, 127, low, high)) \ + | EFCT_INSERT64(64, 127, low, high, value)); \ + } while (0) + +#define EFCT_SET_QWORD64 (qword, low, high, value) \ + (qword).u64[0] = (((qword).u64[0] \ + & ~EFCT_INPLACE_MASK64(0, 63, low, high)) \ + | EFCT_INSERT64(0, 63, low, high, value)) \ + +#define EFCT_SET_OWORD32 (oword, low, high, value) do { \ + (oword).u32[0] = (((oword).u32[0] \ + & ~EFCT_INPLACE_MASK32(0, 31, low, high)) \ + | EFCT_INSERT32(0, 31, low, high, value)); \ + (oword).u32[1] = (((oword).u32[1] \ + & ~EFCT_INPLACE_MASK32(32, 63, low, high)) \ + | EFCT_INSERT32(32, 63, low, high, value)); \ + (oword).u32[2] = (((oword).u32[2] \ + & ~EFCT_INPLACE_MASK32(64, 95, low, high)) \ + | EFCT_INSERT32(64, 95, low, high, value)); \ + (oword).u32[3] = (((oword).u32[3] \ + & ~EFCT_INPLACE_MASK32(96, 127, low, high)) \ + | EFCT_INSERT32(96, 127, low, high, value)); \ + } while (0) + +#define EFCT_SET_QWORD32 (qword, low, high, value) do { \ + (qword).u32[0] = (((qword).u32[0] \ + & ~EFCT_INPLACE_MASK32(0, 31, low, high)) \ + | EFCT_INSERT32(0, 31, low, high, value)); \ + (qword).u32[1] = (((qword).u32[1] \ + & ~EFCT_INPLACE_MASK32(32, 63, low, high)) \ + | EFCT_INSERT32(32, 63, low, high, value)); \ + } while (0) + +#define EFCT_SET_DWORD32 (dword, low, high, value) \ + (dword).word32 = (((dword).word32 \ + & ~EFCT_INPLACE_MASK32(0, 31, low, high)) \ + | EFCT_INSERT32(0, 31, low, high, value)) \ + +#define EFCT_SET_OWORD_FIELD64 (oword, field, value) \ + EFCT_SET_OWORD64(oword, EFCT_LOW_BIT(field), \ + EFCT_HIGH_BIT(field), value) + +#define EFCT_SET_QWORD_FIELD64 (qword, field, value) \ + EFCT_SET_QWORD64(qword, EFCT_LOW_BIT(field), \ + EFCT_HIGH_BIT(field), value) + +#define EFCT_SET_OWORD_FIELD32 (oword, field, value) \ + EFCT_SET_OWORD32(oword, EFCT_LOW_BIT(field), \ + EFCT_HIGH_BIT(field), value) + +#define EFCT_SET_QWORD_FIELD32 (qword, field, value) \ + EFCT_SET_QWORD32(qword, EFCT_LOW_BIT(field), \ + EFCT_HIGH_BIT(field), value) + +#define EFCT_SET_DWORD_FIELD (dword, field, value) \ + EFCT_SET_DWORD32(dword, EFCT_LOW_BIT(field), \ + EFCT_HIGH_BIT(field), value) + +#if BITS_PER_LONG ==64 +#define EFCT_SET_OWORD_FIELD EFCT_SET_OWORD_FIELD64 +#define EFCT_SET_QWORD_FIELD EFCT_SET_QWORD_FIELD64 +#else +#define EFCT_SET_OWORD_FIELD EFCT_SET_OWORD_FIELD32 +#define EFCT_SET_QWORD_FIELD EFCT_SET_QWORD_FIELD32 +#endif + +/* Static initialiser */ +#define EFCT_OWORD32 (a, b, c, d) \ + { .u32 = { cpu_to_le32(a), cpu_to_le32(b), \ + cpu_to_le32(c), cpu_to_le32(d) } } + +#endif /* EFCT_BITFIELD_H */
drivers/net/ethernet/amd/efct/efct_common.c new file +1154 -0
1,154 lines not on this page · raw message
drivers/net/ethernet/amd/efct/efct_common.h new file +134 -0
134 lines not on this page · raw message
drivers/net/ethernet/amd/efct/efct_driver.h new file +770 -0
770 lines not on this page · raw message
drivers/net/ethernet/amd/efct/efct_enum.h new file +130 -0
130 lines not on this page · raw message
drivers/net/ethernet/amd/efct/efct_evq.c new file +185 -0
185 lines not on this page · raw message
drivers/net/ethernet/amd/efct/efct_evq.h new file +21 -0
@@ -0,0 +1,21 @@ +/* SPDX-License-Identifier: GPL-2.0 +**************************************************************************** +* Driver for AMD/Xilinx network controllers and boards +* Copyright (C) 2021, Xilinx, Inc. +* Copyright (C) 2022-2023, Advanced Micro Devices, Inc. +*/ + +#ifndef EFCT_EVQ_H +#define EFCT_EVQ_H +#include "efct_driver.h" + +int efct_init_napi (struct efct_nic *efct); +void efct_finish_napi (struct efct_nic *efct); +void efct_disable_napi (struct efct_ev_queue *evq); +void efct_enable_napi (struct efct_ev_queue *evq); +void efct_synchronize_napi (struct efct_ev_queue *evq); +void efct_write_evt_prime (struct efct_nic *efct,u32 id,u16 seq); +int efct_realloc_rx_evqs (struct efct_nic *efct,u32 num_entries); +bool efct_nic_event_present (struct efct_ev_queue *evq); +int efct_nic_event_test_irq_cpu (struct efct_ev_queue *evq); +#endif
drivers/net/ethernet/amd/efct/efct_io.h new file +64 -0
64 lines not on this page · raw message
drivers/net/ethernet/amd/efct/efct_netdev.c new file +459 -0
59 lines not on this page · raw message
drivers/net/ethernet/amd/efct/efct_netdev.h new file +19 -0
Lines of this file are not shown. View the raw message.
drivers/net/ethernet/amd/efct/efct_nic.c new file +1300 -0
1,300 lines not on this page · raw message
drivers/net/ethernet/amd/efct/efct_nic.h new file +104 -0
104 lines not on this page · raw message
drivers/net/ethernet/amd/efct/efct_pci.c new file +1077 -0
1,077 lines not on this page · raw message
drivers/net/ethernet/amd/efct/efct_reg.h new file +1060 -0
1,060 lines not on this page · raw message
drivers/net/ethernet/amd/efct/mcdi.c new file +1817 -0
1,817 lines not on this page · raw message
drivers/net/ethernet/amd/efct/mcdi.h new file +373 -0
373 lines not on this page · raw message
drivers/net/ethernet/amd/efct/mcdi_functions.c new file +642 -0
642 lines not on this page · raw message
drivers/net/ethernet/amd/efct/mcdi_functions.h new file +39 -0
Lines of this file are not shown. View the raw message.
drivers/net/ethernet/amd/efct/mcdi_pcol.h new file +5789 -0
5,789 lines not on this page · raw message
drivers/net/ethernet/amd/efct/mcdi_port_common.c new file +949 -0
949 lines not on this page · raw message
drivers/net/ethernet/amd/efct/mcdi_port_common.h new file +98 -0
98 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.25.1
Part of the diff is not shown here. View the raw message.
Re: [PATCH 1/6] net: ethernet: efct: New X3 net driver
Quoted 31 lines · Harsh Jain
This patch series adds new ethernet network driver for Alveo X3522[1]. is a low-latency NIC with an aim to deliver the lowest possible latency. It accelerates a range of diverse trading strategies and financial applications.
Device has 2 PCI functions and each function supports 2 port, currently at 10GbE. This patch deals with PCI device probing and netdev creation. It also adds support for Firmware communication APIs used in later patches.
Signed-off-by Abhijit Gangurde<[email protected]>Signed-off-by Puneet Gupta <[email protected]>Signed-off-by Nikhil Agarwal<[email protected]>Signed-off-by Tarak Reddy<[email protected]>Signed-off-by Harsh Jain <[email protected]>--- drivers/net/ethernet/amd/efct/efct_bitfield.h | 483 ++ drivers/net/ethernet/amd/efct/efct_common.c | 1154 ++++ drivers/net/ethernet/amd/efct/efct_common.h | 134 + drivers/net/ethernet/amd/efct/efct_driver.h | 770 +++ drivers/net/ethernet/amd/efct/efct_enum.h | 130 + drivers/net/ethernet/amd/efct/efct_evq.c | 185 + drivers/net/ethernet/amd/efct/efct_evq.h | 21 + drivers/net/ethernet/amd/efct/efct_io.h | 64 + drivers/net/ethernet/amd/efct/efct_netdev.c | 459 ++ drivers/net/ethernet/amd/efct/efct_netdev.h | 19 + drivers/net/ethernet/amd/efct/efct_nic.c | 1300 ++++ drivers/net/ethernet/amd/efct/efct_nic.h | 104 + drivers/net/ethernet/amd/efct/efct_pci.c | 1077 +++ drivers/net/ethernet/amd/efct/efct_reg.h | 1060 +++
Quoted 8 lines
drivers/net/ethernet/amd/efct/mcdi.c | 1817 ++++++ drivers/net/ethernet/amd/efct/mcdi.h | 373 ++ .../net/ethernet/amd/efct/mcdi_functions.c | 642 ++ .../net/ethernet/amd/efct/mcdi_functions.h | 39 + drivers/net/ethernet/amd/efct/mcdi_pcol.h | 5789 +++++++++++++++++ .../net/ethernet/amd/efct/mcdi_port_common.c | 949 +++ .../net/ethernet/amd/efct/mcdi_port_common.h | 98 + 21 files changed, 16667 insertions(+)
This is a very large patch to review.
Quoted 59 lines
create mode 100644 drivers/net/ethernet/amd/efct/efct_bitfield.h create mode 100644 drivers/net/ethernet/amd/efct/efct_common.c create mode 100644 drivers/net/ethernet/amd/efct/efct_common.h create mode 100644 drivers/net/ethernet/amd/efct/efct_driver.h create mode 100644 drivers/net/ethernet/amd/efct/efct_enum.h create mode 100644 drivers/net/ethernet/amd/efct/efct_evq.c create mode 100644 drivers/net/ethernet/amd/efct/efct_evq.h create mode 100644 drivers/net/ethernet/amd/efct/efct_io.h create mode 100644 drivers/net/ethernet/amd/efct/efct_netdev.c create mode 100644 drivers/net/ethernet/amd/efct/efct_netdev.h create mode 100644 drivers/net/ethernet/amd/efct/efct_nic.c create mode 100644 drivers/net/ethernet/amd/efct/efct_nic.h create mode 100644 drivers/net/ethernet/amd/efct/efct_pci.c create mode 100644 drivers/net/ethernet/amd/efct/efct_reg.h create mode 100644 drivers/net/ethernet/amd/efct/mcdi.c create mode 100644 drivers/net/ethernet/amd/efct/mcdi.h create mode 100644 drivers/net/ethernet/amd/efct/mcdi_functions.c create mode 100644 drivers/net/ethernet/amd/efct/mcdi_functions.h create mode 100644 drivers/net/ethernet/amd/efct/mcdi_pcol.h create mode 100644 drivers/net/ethernet/amd/efct/mcdi_port_common.c create mode 100644 drivers/net/ethernet/amd/efct/mcdi_port_common.hdrivers/net/ethernet/amd/efct/efct_bitfield.h new file +31
-0@@ -0,0 +1,483 @@ +/* SPDX-License-Identifier: GPL-2.0 +**************************************************************************** +* Driver for AMD/Xilinx network controllers and boards +* Copyright (C) 2021, Xilinx, Inc. +* Copyright (C) 2022-2023, Advanced Micro Devices, Inc. +*/ + +#ifndef EFCT_BITFIELD_H +#define EFCT_BITFIELD_H +#include <linux/types.h> + +/* Efct bitfield access +* NIC uses bitfield of upto 128 bits wide. Since there is no +* native 128-bit datatype on most systems, and 64-bit datatypes +* are inefficient on 32-bit systems and vice versa, +* we wrap accesses in a way that uses the most efficient +* datatype. +* +* The NICs are PCI devices and therefore little-endian. Since most +* of the quantities that we deal with are DMAed to/from host memory, +* we define our datatypes (union efct_oword, union efct_dword and +* union efct_qword) to be little-endian. +*/ + +/* Lowest bit numbers and widths */ +#define EFCT_DUMMY_FIELD_LBN 0 +#define EFCT_DUMMY_FIELD_WIDTH 0 +#define EFCT_WORD_0_LBN 0 +#define EFCT_WORD_0_WIDTH 16 +#define EFCT_WORD_1_LBN 16 +#define EFCT_WORD_1_WIDTH 16
drivers/net/ethernet/amd/efct/efct_bitfield.h line 41
Quoted 10 lines
drivers/net/ethernet/amd/efct/efct_bitfield.h new file +10
-0+#define EFCT_DWORD_0_LBN 0 +#define EFCT_DWORD_0_WIDTH 32 +#define EFCT_DWORD_1_LBN 32 +#define EFCT_DWORD_1_WIDTH 32 +#define EFCT_DWORD_2_LBN 64 +#define EFCT_DWORD_2_WIDTH 32 +#define EFCT_DWORD_3_LBN 96 +#define EFCT_DWORD_3_WIDTH 32 +#define EFCT_QWORD_0_LBN 0 +#define EFCT_QWORD_0_WIDTH 64
nit: The above would be easier to read if the values were vertically aligned nit 2: blank line here
drivers/net/ethernet/amd/efct/efct_bitfield.h line 49
Quoted 9 lines
drivers/net/ethernet/amd/efct/efct_bitfield.h new file +8
-0+/* Specified attribute (e.g. LBN) of the specified field */ +#define EFCT_VAL (field, attribute) field ## _ ## attribute +/* Low bit number of the specified field */ +#define EFCT_LOW_BIT (field) EFCT_VAL(field, LBN) +/* Bit width of the specified field */ +#define EFCT_WIDTH (field) EFCT_VAL(field, WIDTH) +/* High bit number of the specified field */ +#define EFCT_HIGH_BIT (field) (EFCT_LOW_BIT(field) + EFCT_WIDTH(field) - 1)
nit2: and here
drivers/net/ethernet/amd/efct/efct_bitfield.h line 58
Quoted 9 lines
drivers/net/ethernet/amd/efct/efct_bitfield.h new file +9
-0+/* Mask equal in width to the specified field. +* +* For example, a field with width 5 would have a mask of 0x1f. +* +* The maximum width mask that can be generated is 64 bits. +*/ +#define EFCT_MASK64 (width) \ + ((width) == 64 ? ~((u64)0) : \ + (((((u64)1) << (width))) - 1))
Maybe:
#define EFCT_MASK64_B(width) ((width) ? GENMASK_ULL((width) - 1, 0) : 0ULL)
drivers/net/ethernet/amd/efct/efct_bitfield.h
Quoted 11 lines
drivers/net/ethernet/amd/efct/efct_bitfield.h new file +10
-0+ +/* Mask equal in width to the specified field. +* +* For example, a field with width 5 would have a mask of 0x1f. +* +* The maximum width mask that can be generated is 32 bits. Use +* EFCT_MASK64 for higher width fields. +*/ +#define EFCT_MASK32 (width) \ + ((width) == 32 ? ~((u32)0) : \ + (((((u32)1) << (width))) - 1))
Maybe:
#define EFCT_MASK32_B(width) ((width) ? GENMASK((width) - 1, 0) : 0UL)
drivers/net/ethernet/amd/efct/efct_bitfield.h line 74
Quoted 5 lines
drivers/net/ethernet/amd/efct/efct_bitfield.h new file +5
-0+ +/* A doubleword (i.e. 4 byte) datatype - little-endian in HW */ +union efct_dword { +__le32 word32; +};
I see where you are going with consistency forefct_dword, efct_qword and efct_oword.
But does a union with one element provide value?
drivers/net/ethernet/amd/efct/efct_bitfield.h line 80
Quoted 6 lines
drivers/net/ethernet/amd/efct/efct_bitfield.h new file +6
-0+ +/* A quadword (i.e. 8 byte) datatype - little-endian in HW */ +union efct_qword { +__le64 u64[1 ]; +__le32 u32[2 ]; +union efct_dword dword[2 ];
dword is an alias for .ue2. I'm not sure I see the value in this.
drivers/net/ethernet/amd/efct/efct_bitfield.h line 88
Quoted 8 lines
drivers/net/ethernet/amd/efct/efct_bitfield.h new file +8
-0+}; + +/* An octword (eight-word, i.e. 16 byte) datatype - little-endian in HW */ +union efct_oword { +__le64 u64[2 ]; +union efct_qword qword[2 ]; +__le32 u32[4 ]; +union efct_dword dword[4 ];
ditto
Quoted 8 lines
drivers/net/ethernet/amd/efct/efct_bitfield.h new file +8
-0+}; + +/* Format string and value expanders for printk */ +#define EFCT_DWORD_FMT "%08x" +#define EFCT_OWORD_FMT "%08x:%08x:%08x:%08x" +#define EFCT_DWORD_VAL (dword) \ + ((u32)le32_to_cpu((dword).word32)) +
drivers/net/ethernet/amd/efct/efct_bitfield.h line 106
Quoted 10 lines
drivers/net/ethernet/amd/efct/efct_bitfield.h new file +10
-0+/* Extract bit field portion [low,high) from the native-endian element +* which contains bits [min,max). +* For example, suppose "element" represents the high 32 bits of a +* 64-bit value, and we wish to extract the bits belonging to the bit +* field occupying bits 28-45 of this 64-bit value. +* Then EFCT_EXTRACT ( element, 32, 63, 28, 45 ) would give +* +* ( element ) << 4 +* The result will contain the relevant bits filled in the range +* [0,high-low), with garbage in bits [high-low+1,...).
In this case [0,min-low) will be zero filled.
But maybe that never happens so it's not important that it is spelt out.
Garbage bits sounds fun.
Did you consider implementing this using GET_FIELD and GENMASK_ULL?
Quoted 360 lines
+ */
drivers/net/ethernet/amd/efct/efct_bitfield.h new file +359
-0+#define EFCT_EXTRACT_NATIVE (native_element, min, max, low, high) \ + ((low) > (max) || (high) < (min) ? 0 : \ + (low) > (min) ? \ + (native_element) >> ((low) - (min)) : \ + (native_element) << ((min) - (low))) + +/* Extract bit field portion [low,high) from the 64-bit little-endian +* element which contains bits [min,max) +*/ +#define EFCT_EXTRACT64 (element, min, max, low, high) \ + EFCT_EXTRACT_NATIVE(le64_to_cpu(element), min, max, low, high) + +/* Extract bit field portion [low,high) from the 32-bit little-endian +* element which contains bits [min,max) +*/ +#define EFCT_EXTRACT32 (element, min, max, low, high) \ + EFCT_EXTRACT_NATIVE(le32_to_cpu(element), min, max, low, high) + +#define EFCT_EXTRACT_OWORD64 (oword, low, high) \ + ((EFCT_EXTRACT64((oword).u64[0], 0, 63, low, high) | \ + EFCT_EXTRACT64((oword).u64[1], 64, 127, low, high)) & \ + EFCT_MASK64((high) + 1 - (low))) + +#define EFCT_EXTRACT_QWORD64 (qword, low, high) \ + (EFCT_EXTRACT64((qword).u64[0], 0, 63, low, high) & \ + EFCT_MASK64((high) + 1 - (low))) + +#define EFCT_EXTRACT_OWORD32 (oword, low, high) \ + ((EFCT_EXTRACT32((oword).u32[0], 0, 31, low, high) | \ + EFCT_EXTRACT32((oword).u32[1], 32, 63, low, high) | \ + EFCT_EXTRACT32((oword).u32[2], 64, 95, low, high) | \ + EFCT_EXTRACT32((oword).u32[3], 96, 127, low, high)) & \ + EFCT_MASK32((high) + 1 - (low))) + +#define EFCT_EXTRACT_QWORD32 (qword, low, high) \ + ((EFCT_EXTRACT32((qword).u32[0], 0, 31, low, high) | \ + EFCT_EXTRACT32((qword).u32[1], 32, 63, low, high)) & \ + EFCT_MASK32((high) + 1 - (low))) + +#define EFCT_EXTRACT_DWORD (dword, low, high) \ + (EFCT_EXTRACT32((dword).word32, 0, 31, low, high) & \ + EFCT_MASK32((high) + 1 - (low))) + +#define EFCT_OWORD_FIELD64 (oword, field) \ + EFCT_EXTRACT_OWORD64(oword, EFCT_LOW_BIT(field), \ + EFCT_HIGH_BIT(field)) + +#define EFCT_QWORD_FIELD64 (qword, field) \ + EFCT_EXTRACT_QWORD64(qword, EFCT_LOW_BIT(field), \ + EFCT_HIGH_BIT(field)) + +#define EFCT_OWORD_FIELD32 (oword, field) \ + EFCT_EXTRACT_OWORD32(oword, EFCT_LOW_BIT(field), \ + EFCT_HIGH_BIT(field)) + +#define EFCT_QWORD_FIELD32 (qword, field) \ + EFCT_EXTRACT_QWORD32(qword, EFCT_LOW_BIT(field), \ + EFCT_HIGH_BIT(field)) + +#define EFCT_DWORD_FIELD (dword, field) \ + EFCT_EXTRACT_DWORD(dword, EFCT_LOW_BIT(field), \ + EFCT_HIGH_BIT(field)) + +#define EFCT_OWORD_IS_ZERO64 (oword) \ + (((oword).u64[0] | (oword).u64[1]) == (__force __le64)0) + +#define EFCT_QWORD_IS_ZERO64 (qword) \ + (((qword).u64[0]) == (__force __le64)0) + +#define EFCT_OWORD_IS_ZERO32 (oword) \ + (((oword).u32[0] | (oword).u32[1] | (oword).u32[2] | (oword).u32[3]) \ + == (__force __le32)0) + +#define EFCT_QWORD_IS_ZERO32 (qword) \ + (((qword).u32[0] | (qword).u32[1]) == (__force __le32)0) + +#define EFCT_DWORD_IS_ZERO (dword) \ + (((dword).u32[0]) == (__force __le32)0) + +#define EFCT_OWORD_IS_ALL_ONES64 (oword) \ + (((oword).u64[0] & (oword).u64[1]) == ~((__force __le64)0)) + +#define EFCT_QWORD_IS_ALL_ONES64 (qword) \ + ((qword).u64[0] == ~((__force __le64)0)) + +#define EFCT_OWORD_IS_ALL_ONES32 (oword) \ + (((oword).u32[0] & (oword).u32[1] & (oword).u32[2] & (oword).u32[3]) \ + == ~((__force __le32)0)) + +#define EFCT_QWORD_IS_ALL_ONES32 (qword) \ + (((qword).u32[0] & (qword).u32[1]) == ~((__force __le32)0)) + +#define EFCT_DWORD_IS_ALL_ONES (dword) \ + ((dword).u32[0] == ~((__force __le32)0)) + +#if BITS_PER_LONG ==64 +#define EFCT_OWORD_FIELD EFCT_OWORD_FIELD64 +#define EFCT_QWORD_FIELD EFCT_QWORD_FIELD64 +#define EFCT_OWORD_IS_ZERO EFCT_OWORD_IS_ZERO64 +#define EFCT_QWORD_IS_ZERO EFCT_QWORD_IS_ZERO64 +#define EFCT_OWORD_IS_ALL_ONES EFCT_OWORD_IS_ALL_ONES64 +#define EFCT_QWORD_IS_ALL_ONES EFCT_QWORD_IS_ALL_ONES64 +#else +#define EFCT_OWORD_FIELD EFCT_OWORD_FIELD32 +#define EFCT_QWORD_FIELD EFCT_QWORD_FIELD32 +#define EFCT_OWORD_IS_ZERO EFCT_OWORD_IS_ZERO32 +#define EFCT_QWORD_IS_ZERO EFCT_QWORD_IS_ZERO32 +#define EFCT_OWORD_IS_ALL_ONES EFCT_OWORD_IS_ALL_ONES32 +#define EFCT_QWORD_IS_ALL_ONES EFCT_QWORD_IS_ALL_ONES32 +#endif + +/* Construct bit field portion +* Creates the portion of the bit field [low,high) that lies within +* the range [min,max). +*/ +#define EFCT_INSERT_NATIVE64 (min, max, low, high, value) \ + ((((low) > (max)) || ((high) < (min))) ? 0 : \ + (((low) > (min)) ? \ + (((u64)(value)) << ((low) - (min))) : \ + (((u64)(value)) >> ((min) - (low))))) + +#define EFCT_INSERT_NATIVE32 (min, max, low, high, value) \ + ((((low) > (max)) || ((high) < (min))) ? 0 : \ + (((low) > (min)) ? \ + (((u32)(value)) << ((low) - (min))) : \ + (((u32)(value)) >> ((min) - (low))))) + +#define EFCT_INSERT_NATIVE (min, max, low, high, value) \ + (((((max) - (min)) >= 32) || (((high) - (low)) >= 32)) ? \ + EFCT_INSERT_NATIVE64(min, max, low, high, value) : \ + EFCT_INSERT_NATIVE32(min, max, low, high, value)) + +/* Construct bit field portion +* Creates the portion of the named bit field that lies within the +* range [min,max). +*/ +#define EFCT_INSERT_FIELD_NATIVE (min, max, field, value) \ + EFCT_INSERT_NATIVE(min, max, EFCT_LOW_BIT(field), \ + EFCT_HIGH_BIT(field), value) + +/* Construct bit field +* Creates the portion of the named bit fields that lie within the +* range [min,max). +*/ +#define EFCT_INSERT_FIELDS_NATIVE (_min, _max, \ + field1, value1, \ + field2, value2, \ + field3, value3, \ + field4, value4, \ + field5, value5, \ + field6, value6, \ + field7, value7, \ + field8, value8, \ + field9, value9, \ + field10, value10) \ + ({typeof(_min) (min) = (_min); \ + typeof(_max) (max) = (_max); \ + EFCT_INSERT_FIELD_NATIVE((min), (max), field1, (value1)) | \ + EFCT_INSERT_FIELD_NATIVE((min), (max), field2, (value2)) | \ + EFCT_INSERT_FIELD_NATIVE((min), (max), field3, (value3)) | \ + EFCT_INSERT_FIELD_NATIVE((min), (max), field4, (value4)) | \ + EFCT_INSERT_FIELD_NATIVE((min), (max), field5, (value5)) | \ + EFCT_INSERT_FIELD_NATIVE((min), (max), field6, (value6)) | \ + EFCT_INSERT_FIELD_NATIVE((min), (max), field7, (value7)) | \ + EFCT_INSERT_FIELD_NATIVE((min), (max), field8, (value8)) | \ + EFCT_INSERT_FIELD_NATIVE((min), (max), field9, (value9)) | \ + EFCT_INSERT_FIELD_NATIVE((min), (max), field10, (value10)); }) + +#define EFCT_INSERT_FIELDS64 (...) \ + cpu_to_le64(EFCT_INSERT_FIELDS_NATIVE(__VA_ARGS__)) + +#define EFCT_INSERT_FIELDS32 (...) \ + cpu_to_le32(EFCT_INSERT_FIELDS_NATIVE(__VA_ARGS__)) + +#define EFCT_POPULATE_OWORD64 (oword, ...) do { \ + (oword).u64[0] = EFCT_INSERT_FIELDS64(0, 63, __VA_ARGS__); \ + (oword).u64[1] = EFCT_INSERT_FIELDS64(64, 127, __VA_ARGS__); \ + } while (0) + +#define EFCT_POPULATE_QWORD64 (qword, ...) (qword).u64[0] = EFCT_INSERT_FIELDS64(0, 63, __VA_ARGS__) + +#define EFCT_POPULATE_OWORD32 (oword, ...) do { \ + (oword).u32[0] = EFCT_INSERT_FIELDS32(0, 31, __VA_ARGS__); \ + (oword).u32[1] = EFCT_INSERT_FIELDS32(32, 63, __VA_ARGS__); \ + (oword).u32[2] = EFCT_INSERT_FIELDS32(64, 95, __VA_ARGS__); \ + (oword).u32[3] = EFCT_INSERT_FIELDS32(96, 127, __VA_ARGS__); \ + } while (0) + +#define EFCT_POPULATE_QWORD32 (qword, ...) do { \ + (qword).u32[0] = EFCT_INSERT_FIELDS32(0, 31, __VA_ARGS__); \ + (qword).u32[1] = EFCT_INSERT_FIELDS32(32, 63, __VA_ARGS__); \ + } while (0) + +#define EFCT_POPULATE_DWORD (dword, ...) (dword).word32 = EFCT_INSERT_FIELDS32(0, 31, __VA_ARGS__) + +#if BITS_PER_LONG ==64 +#define EFCT_POPULATE_OWORD EFCT_POPULATE_OWORD64 +#define EFCT_POPULATE_QWORD EFCT_POPULATE_QWORD64 +#else +#define EFCT_POPULATE_OWORD EFCT_POPULATE_OWORD32 +#define EFCT_POPULATE_QWORD EFCT_POPULATE_QWORD32 +#endif + +/* Populate an octword field with various numbers of arguments */ +#define EFCT_POPULATE_OWORD_10 EFCT_POPULATE_OWORD +#define EFCT_POPULATE_OWORD_9 (oword, ...) \ + EFCT_POPULATE_OWORD_10(oword, EFCT_DUMMY_FIELD, 0, __VA_ARGS__) +#define EFCT_POPULATE_OWORD_8 (oword, ...) \ + EFCT_POPULATE_OWORD_9(oword, EFCT_DUMMY_FIELD, 0, __VA_ARGS__) +#define EFCT_POPULATE_OWORD_7 (oword, ...) \ + EFCT_POPULATE_OWORD_8(oword, EFCT_DUMMY_FIELD, 0, __VA_ARGS__) +#define EFCT_POPULATE_OWORD_6 (oword, ...) \ + EFCT_POPULATE_OWORD_7(oword, EFCT_DUMMY_FIELD, 0, __VA_ARGS__) +#define EFCT_POPULATE_OWORD_5 (oword, ...) \ + EFCT_POPULATE_OWORD_6(oword, EFCT_DUMMY_FIELD, 0, __VA_ARGS__) +#define EFCT_POPULATE_OWORD_4 (oword, ...) \ + EFCT_POPULATE_OWORD_5(oword, EFCT_DUMMY_FIELD, 0, __VA_ARGS__) +#define EFCT_POPULATE_OWORD_3 (oword, ...) \ + EFCT_POPULATE_OWORD_4(oword, EFCT_DUMMY_FIELD, 0, __VA_ARGS__) +#define EFCT_POPULATE_OWORD_2 (oword, ...) \ + EFCT_POPULATE_OWORD_3(oword, EFCT_DUMMY_FIELD, 0, __VA_ARGS__) +#define EFCT_POPULATE_OWORD_1 (oword, ...) \ + EFCT_POPULATE_OWORD_2(oword, EFCT_DUMMY_FIELD, 0, __VA_ARGS__) +#define EFCT_ZERO_OWORD (oword) \ + EFCT_POPULATE_OWORD_1(oword, EFCT_DUMMY_FIELD, 0) +#define EFCT_SET_OWORD (oword) \ + EFCT_POPULATE_OWORD_4(oword, \ + EFCT_DWORD_0, 0xffffffff, \ + EFCT_DWORD_1, 0xffffffff, \ + EFCT_DWORD_2, 0xffffffff, \ + EFCT_DWORD_3, 0xffffffff) + +/* Populate a quadword field with various numbers of arguments */ +#define EFCT_POPULATE_QWORD_10 EFCT_POPULATE_QWORD +#define EFCT_POPULATE_QWORD_9 (qword, ...) \ + EFCT_POPULATE_QWORD_10(qword, EFCT_DUMMY_FIELD, 0, __VA_ARGS__) +#define EFCT_POPULATE_QWORD_8 (qword, ...) \ + EFCT_POPULATE_QWORD_9(qword, EFCT_DUMMY_FIELD, 0, __VA_ARGS__) +#define EFCT_POPULATE_QWORD_7 (qword, ...) \ + EFCT_POPULATE_QWORD_8(qword, EFCT_DUMMY_FIELD, 0, __VA_ARGS__) +#define EFCT_POPULATE_QWORD_6 (qword, ...) \ + EFCT_POPULATE_QWORD_7(qword, EFCT_DUMMY_FIELD, 0, __VA_ARGS__) +#define EFCT_POPULATE_QWORD_5 (qword, ...) \ + EFCT_POPULATE_QWORD_6(qword, EFCT_DUMMY_FIELD, 0, __VA_ARGS__) +#define EFCT_POPULATE_QWORD_4 (qword, ...) \ + EFCT_POPULATE_QWORD_5(qword, EFCT_DUMMY_FIELD, 0, __VA_ARGS__) +#define EFCT_POPULATE_QWORD_3 (qword, ...) \ + EFCT_POPULATE_QWORD_4(qword, EFCT_DUMMY_FIELD, 0, __VA_ARGS__) +#define EFCT_POPULATE_QWORD_2 (qword, ...) \ + EFCT_POPULATE_QWORD_3(qword, EFCT_DUMMY_FIELD, 0, __VA_ARGS__) +#define EFCT_POPULATE_QWORD_1 (qword, ...) \ + EFCT_POPULATE_QWORD_2(qword, EFCT_DUMMY_FIELD, 0, __VA_ARGS__) +#define EFCT_ZERO_QWORD (qword) \ + EFCT_POPULATE_QWORD_1(qword, EFCT_DUMMY_FIELD, 0) +#define EFCT_SET_QWORD (qword) \ + EFCT_POPULATE_QWORD_2(qword, \ + EFCT_DWORD_0, 0xffffffff, \ + EFCT_DWORD_1, 0xffffffff) +/* Populate a dword field with various numbers of arguments */ +#define EFCT_POPULATE_DWORD_10 EFCT_POPULATE_DWORD +#define EFCT_POPULATE_DWORD_9 (dword, ...) \ + EFCT_POPULATE_DWORD_10(dword, EFCT_DUMMY_FIELD, 0, __VA_ARGS__) +#define EFCT_POPULATE_DWORD_8 (dword, ...) \ + EFCT_POPULATE_DWORD_9(dword, EFCT_DUMMY_FIELD, 0, __VA_ARGS__) +#define EFCT_POPULATE_DWORD_7 (dword, ...) \ + EFCT_POPULATE_DWORD_8(dword, EFCT_DUMMY_FIELD, 0, __VA_ARGS__) +#define EFCT_POPULATE_DWORD_6 (dword, ...) \ + EFCT_POPULATE_DWORD_7(dword, EFCT_DUMMY_FIELD, 0, __VA_ARGS__) +#define EFCT_POPULATE_DWORD_5 (dword, ...) \ + EFCT_POPULATE_DWORD_6(dword, EFCT_DUMMY_FIELD, 0, __VA_ARGS__) +#define EFCT_POPULATE_DWORD_4 (dword, ...) \ + EFCT_POPULATE_DWORD_5(dword, EFCT_DUMMY_FIELD, 0, __VA_ARGS__) +#define EFCT_POPULATE_DWORD_3 (dword, ...) \ + EFCT_POPULATE_DWORD_4(dword, EFCT_DUMMY_FIELD, 0, __VA_ARGS__) +#define EFCT_POPULATE_DWORD_2 (dword, ...) \ + EFCT_POPULATE_DWORD_3(dword, EFCT_DUMMY_FIELD, 0, __VA_ARGS__) +#define EFCT_POPULATE_DWORD_1 (dword, ...) \ + EFCT_POPULATE_DWORD_2(dword, EFCT_DUMMY_FIELD, 0, __VA_ARGS__) +#define EFCT_ZERO_DWORD (dword) \ + EFCT_POPULATE_DWORD_1(dword, EFCT_DUMMY_FIELD, 0) +#define EFCT_SET_DWORD (dword) \ + EFCT_POPULATE_DWORD_1(dword, EFCT_DWORD_0, 0xffffffff) + +/* Modify a named field within an already-populated structure. Used +* for read-modify-write operations. +*/ + +#define EFCT_INSERT64 (min, max, low, high, value) \ + cpu_to_le64(EFCT_INSERT_NATIVE(min, max, low, high, value)) + +#define EFCT_INSERT32 (min, max, low, high, value) \ + cpu_to_le32(EFCT_INSERT_NATIVE(min, max, low, high, value)) + +#define EFCT_INPLACE_MASK64 (min, max, low, high) \ + EFCT_INSERT64(min, max, low, high, EFCT_MASK64((high) + 1 - (low))) + +#define EFCT_INPLACE_MASK32 (min, max, low, high) \ + EFCT_INSERT32(min, max, low, high, EFCT_MASK32((high) + 1 - (low))) + +#define EFCT_SET_OWORD64 (oword, low, high, value) do { \ + (oword).u64[0] = (((oword).u64[0] \ + & ~EFCT_INPLACE_MASK64(0, 63, low, high)) \ + | EFCT_INSERT64(0, 63, low, high, value)); \ + (oword).u64[1] = (((oword).u64[1] \ + & ~EFCT_INPLACE_MASK64(64, 127, low, high)) \ + | EFCT_INSERT64(64, 127, low, high, value)); \ + } while (0) + +#define EFCT_SET_QWORD64 (qword, low, high, value) \ + (qword).u64[0] = (((qword).u64[0] \ + & ~EFCT_INPLACE_MASK64(0, 63, low, high)) \ + | EFCT_INSERT64(0, 63, low, high, value)) \ + +#define EFCT_SET_OWORD32 (oword, low, high, value) do { \ + (oword).u32[0] = (((oword).u32[0] \ + & ~EFCT_INPLACE_MASK32(0, 31, low, high)) \ + | EFCT_INSERT32(0, 31, low, high, value)); \ + (oword).u32[1] = (((oword).u32[1] \ + & ~EFCT_INPLACE_MASK32(32, 63, low, high)) \ + | EFCT_INSERT32(32, 63, low, high, value)); \ + (oword).u32[2] = (((oword).u32[2] \ + & ~EFCT_INPLACE_MASK32(64, 95, low, high)) \ + | EFCT_INSERT32(64, 95, low, high, value)); \ + (oword).u32[3] = (((oword).u32[3] \ + & ~EFCT_INPLACE_MASK32(96, 127, low, high)) \ + | EFCT_INSERT32(96, 127, low, high, value)); \ + } while (0) + +#define EFCT_SET_QWORD32 (qword, low, high, value) do { \ + (qword).u32[0] = (((qword).u32[0] \ + & ~EFCT_INPLACE_MASK32(0, 31, low, high)) \ + | EFCT_INSERT32(0, 31, low, high, value)); \ + (qword).u32[1] = (((qword).u32[1] \ + & ~EFCT_INPLACE_MASK32(32, 63, low, high)) \ + | EFCT_INSERT32(32, 63, low, high, value)); \ + } while (0) + +#define EFCT_SET_DWORD32 (dword, low, high, value) \ + (dword).word32 = (((dword).word32 \ + & ~EFCT_INPLACE_MASK32(0, 31, low, high)) \ + | EFCT_INSERT32(0, 31, low, high, value)) \ + +#define EFCT_SET_OWORD_FIELD64 (oword, field, value) \ + EFCT_SET_OWORD64(oword, EFCT_LOW_BIT(field), \ + EFCT_HIGH_BIT(field), value) + +#define EFCT_SET_QWORD_FIELD64 (qword, field, value) \ + EFCT_SET_QWORD64(qword, EFCT_LOW_BIT(field), \ + EFCT_HIGH_BIT(field), value) + +#define EFCT_SET_OWORD_FIELD32 (oword, field, value) \ + EFCT_SET_OWORD32(oword, EFCT_LOW_BIT(field), \ + EFCT_HIGH_BIT(field), value) + +#define EFCT_SET_QWORD_FIELD32 (qword, field, value) \ + EFCT_SET_QWORD32(qword, EFCT_LOW_BIT(field), \ + EFCT_HIGH_BIT(field), value) + +#define EFCT_SET_DWORD_FIELD (dword, field, value) \
drivers/net/ethernet/amd/efct/efct_bitfield.h line 476
Quoted 10 lines
drivers/net/ethernet/amd/efct/efct_bitfield.h new file +10
-0+EFCT_SET_DWORD32 (dword,EFCT_LOW_BIT (field), \ + EFCT_HIGH_BIT(field), value) + +#if BITS_PER_LONG ==64 +#define EFCT_SET_OWORD_FIELD EFCT_SET_OWORD_FIELD64 +#define EFCT_SET_QWORD_FIELD EFCT_SET_QWORD_FIELD64 +#else +#define EFCT_SET_OWORD_FIELD EFCT_SET_OWORD_FIELD32 +#define EFCT_SET_QWORD_FIELD EFCT_SET_QWORD_FIELD32 +#endif
EFCT_SET_OWORD_FIELD and EFCT_SET_QWORD_FIELD are appear to be unused in this patchst. I did not look carefully for other unused defines.
drivers/net/ethernet/amd/efct/efct_bitfield.h line 483
Quoted 7 lines
drivers/net/ethernet/amd/efct/efct_bitfield.h new file +7
-0+ +/* Static initialiser */ +#define EFCT_OWORD32 (a, b, c, d) \ + { .u32 = { cpu_to_le32(a), cpu_to_le32(b), \ + cpu_to_le32(c), cpu_to_le32(d) } } + +#endif /* EFCT_BITFIELD_H */
I'm stopping my review here (because I've run out of time for now).
PATCH 2/6 net: ethernet: efct: Add datapath
In reply to Harsh JainThis patch adds the driver's data path.
Tx:
TX path operates in Cut Through Programmed Input/Output (CTPIO). packets are streamed directly from the PCIe interface to the adapter port to deliver in lowest TX latency. It waits for certain threshold bytes to be available before starting to stream packet data from the FIFO to the MAC. The NIC computes the FCS for the Ethernet frame and host is expected to supply the packet with all other checksums.
Rx:
Driver posts 1MB buffer to NIC. NIC will split those buffer into fixed size(configured in queue setup) packet buffers. NIC DMA the packet in along with metadata(length, timestamp, checksum etc) of previous packet. In case there is no following packet H/W will only write metadata in packet buffer.
--- drivers/net/ethernet/amd/efct/efct_netdev.c | 17 + drivers/net/ethernet/amd/efct/efct_nic.c | 197 +++++++ drivers/net/ethernet/amd/efct/efct_rx.c | 556 ++++++++++++++++++++ drivers/net/ethernet/amd/efct/efct_rx.h | 22 + drivers/net/ethernet/amd/efct/efct_tx.c | 313 +++++++++++ drivers/net/ethernet/amd/efct/efct_tx.h | 17 + 6 files changed, 1122 insertions(+) create mode 100644 drivers/net/ethernet/amd/efct/efct_rx.c create mode 100644 drivers/net/ethernet/amd/efct/efct_rx.h create mode 100644 drivers/net/ethernet/amd/efct/efct_tx.c create mode 100644 drivers/net/ethernet/amd/efct/efct_tx.h
drivers/net/ethernet/amd/efct/efct_netdev.c +17 -0
@@ -221,6 +221,22 @@ static int efct_net_stop(struct net_device *net_dev)return 0 ; } +static netdev_tx_t efct_start_xmit (struct sk_buff *skb,struct net_device *net_dev) +{ +struct efct_nic *efct =efct_netdev_priv (net_dev); +struct efct_tx_queue *tx_queue; +int qid; +int rc; + + qid =skb_get_queue_mapping (skb); + tx_queue = &efct->txq[qid]; + rc =efct_enqueue_skb (tx_queue, skb, net_dev); +if (rc) +atomic64_inc (&tx_queue->efct->n_tx_sw_drops); + +return NETDEV_TX_OK ; +} +/* Context: netif_tx_lock held, BHs disabled. */ static void efct_watchdog (struct net_device *net_dev,unsigned int txqueue) {
@@ -304,6 +320,7 @@ static void efct_net_stats(struct net_device *net_dev, struct rtnl_link_stats64static const struct net_device_ops efct_netdev_ops = { .ndo_open = efct_net_open, .ndo_stop = efct_net_stop, + .ndo_start_xmit = efct_start_xmit, .ndo_tx_timeout = efct_watchdog, .ndo_get_stats64 = efct_net_stats, .ndo_eth_ioctl = efct_eth_ioctl,
drivers/net/ethernet/amd/efct/efct_nic.c +197 -0
221 lines not on this page · raw message
drivers/net/ethernet/amd/efct/efct_rx.c new file +556 -0
556 lines not on this page · raw message
drivers/net/ethernet/amd/efct/efct_rx.h new file +22 -0
@@ -0,0 +1,22 @@ +/* SPDX-License-Identifier: GPL-2.0 +**************************************************************************** +* Driver for AMD/Xilinx network controllers and boards +* Copyright (C) 2021, Xilinx, Inc. +* Copyright (C) 2022-2023, Advanced Micro Devices, Inc. +*/ + +#ifndef EFCT_EFCT_RX_H +#define EFCT_EFCT_RX_H + +#include "efct_driver.h" +/*Count to wait for in case of sentinel mismatch*/ +#define SENTINEL_MISMATCH_COUNT 2000 + +int dbl_init (struct efct_rx_queue *rxq); +void dbl_fini (struct efct_rx_queue *rxq); +int nbl_init (struct efct_rx_queue *rxq); +void nbl_reset (struct efct_rx_queue *rxq); +int efct_fill_rx_buffs (struct efct_rx_queue *rxq); +void efct_ev_rx (struct efct_rx_queue *rxq,const union efct_qword *p_event); + +#endif
drivers/net/ethernet/amd/efct/efct_tx.c new file +313 -0
313 lines not on this page · raw message
drivers/net/ethernet/amd/efct/efct_tx.h new file +17 -0
@@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: GPL-2.0 +**************************************************************************** +* Driver for AMD/Xilinx network controllers and boards +* Copyright (C) 2021, Xilinx, Inc. +* Copyright (C) 2022-2023, Advanced Micro Devices, Inc. +*/ + +#ifndef EFCT_EFCT_TX_H +#define EFCT_EFCT_TX_H + +#include "efct_driver.h" + +int efct_enqueue_skb (struct efct_tx_queue *tx_queue,struct sk_buff *skb, +struct net_device *net_dev); +void efct_ev_tx (struct efct_tx_queue *txq,union efct_qword *p_event,bool purge); +void _efct_ev_tx (struct efct_tx_queue *txq,u8 seq,bool ts_status,u64 partial_ts,bool purge); +#endif
Signature · 1 line
2.25.1
PATCH 3/6 net: ethernet: efct: Add devlink support
In reply to Harsh JainAdd devlink support.
--- drivers/net/ethernet/amd/efct/efct_devlink.c | 829 +++++++++++++++++++ drivers/net/ethernet/amd/efct/efct_devlink.h | 21 + drivers/net/ethernet/amd/efct/efct_driver.h | 3 + drivers/net/ethernet/amd/efct/efct_netdev.c | 1 + drivers/net/ethernet/amd/efct/efct_pci.c | 24 +- drivers/net/ethernet/amd/efct/efct_reflash.c | 564 +++++++++++++ drivers/net/ethernet/amd/efct/efct_reflash.h | 16 + 7 files changed, 1457 insertions(+), 1 deletion(-) create mode 100644 drivers/net/ethernet/amd/efct/efct_devlink.c create mode 100644 drivers/net/ethernet/amd/efct/efct_devlink.h create mode 100644 drivers/net/ethernet/amd/efct/efct_reflash.c create mode 100644 drivers/net/ethernet/amd/efct/efct_reflash.h
drivers/net/ethernet/amd/efct/efct_devlink.c new file +829 -0
@@ -0,0 +1,829 @@ +// SPDX-License-Identifier: GPL-2.0 +/**************************************************************************** +* Driver for AMD/Xilinx network controllers and boards +* Copyright (C) 2021, Xilinx, Inc. +* Copyright (C) 2022-2023, Advanced Micro Devices, Inc. +*/ + +#include <linux/rtc.h> +#include "efct_devlink.h" +#include "mcdi.h" +#include "mcdi_functions.h" +#include "mcdi_pcol.h" +#include "efct_reflash.h" +#include "efct_netdev.h" + +/* Custom devlink-info version object names for details that do not map to the +* generic standardized names. +*/ +#define EFCT_DEVLINK_INFO_VERSION_FW_MGMT_SUC "fw.mgmt.suc" +#define EFCT_DEVLINK_INFO_VERSION_FW_MGMT_CMC "fw.mgmt.cmc" +#define EFCT_DEVLINK_INFO_VERSION_FPGA_REV "fpga.rev" +#define EFCT_DEVLINK_INFO_VERSION_DATAPATH_HW "fpga.app" +#define EFCT_DEVLINK_INFO_VERSION_DATAPATH_FW DEVLINK_INFO_VERSION_GENERIC_FW_APP +#define EFCT_DEVLINK_INFO_VERSION_SOC_BOOT "coproc.boot" +#define EFCT_DEVLINK_INFO_VERSION_SOC_UBOOT "coproc.uboot" +#define EFCT_DEVLINK_INFO_VERSION_SOC_MAIN "coproc.main" +#define EFCT_DEVLINK_INFO_VERSION_SOC_RECOVERY "coproc.recovery" +#define EFCT_DEVLINK_INFO_VERSION_FW_EXPROM "fw.exprom" +#define EFCT_DEVLINK_INFO_VERSION_FW_UEFI "fw.uefi" + +static int efct_devlink_info_user_cfg (struct efct_nic *efct, +struct devlink_info_req *req) +{ +char *buf, *desc; +u16 version[4 ]; +int offset; +int rc; + + offset =0 ; + buf =kmalloc (MC_CMD_NVRAM_METADATA_OUT_DESCRIPTION_MAXNUM_MCDI2 + +EFCT_MAX_VERSION_INFO_LEN ,GFP_KERNEL ); +if (!buf) +return -ENOMEM ; + + desc =kmalloc (MC_CMD_NVRAM_METADATA_OUT_DESCRIPTION_MAXNUM_MCDI2 ,GFP_KERNEL ); +if (!desc) { +kfree (buf); +return -ENOMEM ; + } + + rc =efct_mcdi_nvram_metadata (efct,NVRAM_PARTITION_TYPE_USER_CONFIG ,NULL , version, + desc,MC_CMD_NVRAM_METADATA_OUT_DESCRIPTION_MAXNUM_MCDI2 ); +if (rc) + goto out; +if (version[0 ] || version[1 ] || version[2 ] || version[3 ]) + offset =snprintf (buf, (EFCT_MAX_VERSION_INFO_LEN + +MC_CMD_NVRAM_METADATA_OUT_DESCRIPTION_MAXNUM_MCDI2 ), +"%u.%u.%u.%u " , version[0 ], version[1 ], version[2 ], version[3 ]); + +snprintf (buf + offset, (EFCT_MAX_VERSION_INFO_LEN + +MC_CMD_NVRAM_METADATA_OUT_DESCRIPTION_MAXNUM_MCDI2 ), +"%s" , desc); + +devlink_info_version_stored_put (req,DEVLINK_INFO_VERSION_GENERIC_FW_PSID , buf); + +out: +kfree (buf); +kfree (desc); +return rc; +} + +static int efct_devlink_info_nvram_partition (struct efct_nic *efct, +struct devlink_info_req *req, +u32 partition_type, +const char *version_name) +{ +char buf[EFCT_MAX_VERSION_INFO_LEN ]; +u16 version[4 ]; +int rc; + + rc =efct_mcdi_nvram_metadata (efct, partition_type,NULL , version,NULL ,0 ); +if (rc) +return rc; + +snprintf (buf,EFCT_MAX_VERSION_INFO_LEN ,"%u.%u.%u.%u" , version[0 ], + version[1 ], version[2 ], version[3 ]); +devlink_info_version_stored_put (req, version_name, buf); + +return 0 ; +} + +static void efct_devlink_info_stored_versions (struct efct_nic *efct, +struct devlink_info_req *req) +{ +efct_devlink_info_nvram_partition (efct, req,NVRAM_PARTITION_TYPE_BUNDLE , +DEVLINK_INFO_VERSION_GENERIC_FW_BUNDLE_ID ); +efct_devlink_info_nvram_partition (efct, req, +NVRAM_PARTITION_TYPE_MC_FIRMWARE , +DEVLINK_INFO_VERSION_GENERIC_FW_MGMT ); +efct_devlink_info_nvram_partition (efct, req, +NVRAM_PARTITION_TYPE_SUC_FIRMWARE , +EFCT_DEVLINK_INFO_VERSION_FW_MGMT_SUC ); +efct_devlink_info_nvram_partition (efct, req, +NVRAM_PARTITION_TYPE_EXPANSION_ROM , +EFCT_DEVLINK_INFO_VERSION_FW_EXPROM ); +efct_devlink_info_nvram_partition (efct, req, +NVRAM_PARTITION_TYPE_EXPANSION_UEFI , +EFCT_DEVLINK_INFO_VERSION_FW_UEFI ); +efct_devlink_info_user_cfg (efct, req); +} + +#define EFCT_MAX_SERIALNUM_LEN (ETH_ALEN * 2 + 1) + +static void efct_devlink_info_board_cfg (struct efct_nic *efct, +struct devlink_info_req *req) +{ +char sn[EFCT_MAX_SERIALNUM_LEN ]; +u8 maddr[ETH_ALEN ]; +u32 mac; +int rc; + + mac =0 ; + rc =efct_get_mac_address (efct, maddr); +if (rc) +return ; + mac = maddr[3 ]; + mac = (mac <<8 ) | maddr[4 ]; + mac = (mac <<8 ) | maddr[5 ]; +/* Calculate base mac address of device*/ + mac -= efct->port_num; + maddr[3 ] = (mac >>16 ) &0xff ; + maddr[4 ] = (mac >>8 ) &0xff ; + maddr[5 ] = mac &0xff ; + +snprintf (sn,EFCT_MAX_SERIALNUM_LEN ,"%pm" , maddr); +devlink_info_serial_number_put (req, sn); +} + +#define EFCT_VER_FLAG (_f) \ + (MC_CMD_GET_VERSION_V5_OUT_ ## _f ## _PRESENT_LBN) + +static void efct_devlink_info_running_versions (struct efct_nic *efct, +struct devlink_info_req *req) +{ +MCDI_DECLARE_BUF (outbuf,MC_CMD_GET_VERSION_V5_OUT_LEN ); +MCDI_DECLARE_BUF (inbuf,MC_CMD_GET_VERSION_EXT_IN_LEN ); +char buf[EFCT_MAX_VERSION_INFO_LEN ]; +struct rtc_time build_date; +size_t outlength, offset; +const __le32 *dwords; +const __le16 *words; +u32 flags, build_id; +const char *str; +u64 tstamp; +int rc; + + rc =efct_mcdi_rpc (efct,MC_CMD_GET_VERSION , inbuf,sizeof (inbuf), + outbuf,sizeof (outbuf), &outlength); +if (rc || outlength <MC_CMD_GET_VERSION_V5_OUT_LEN ) +return ; + +/* Handle previous output */ + words = (__le16 *)MCDI_PTR (outbuf, +GET_VERSION_V5_OUT_VERSION ); + offset =snprintf (buf,EFCT_MAX_VERSION_INFO_LEN ,"%u.%u.%u.%u" , +le16_to_cpu (words[0 ]), +le16_to_cpu (words[1 ]), +le16_to_cpu (words[2 ]), +le16_to_cpu (words[3 ])); + +devlink_info_version_running_put (req,DEVLINK_INFO_VERSION_GENERIC_FW_MGMT , buf); + + flags =MCDI_DWORD (outbuf,GET_VERSION_V5_OUT_FLAGS ); +if (flags &BIT (EFCT_VER_FLAG (BOARD_EXT_INFO ))) { +snprintf (buf,EFCT_MAX_VERSION_INFO_LEN ,"%s" , +MCDI_PTR (outbuf,GET_VERSION_V5_OUT_BOARD_NAME )); +devlink_info_version_fixed_put (req,DEVLINK_INFO_VERSION_GENERIC_BOARD_ID , buf); +/* Favour full board version if present (in V5 or later) */ +if (~flags &BIT (EFCT_VER_FLAG (BOARD_VERSION ))) { +snprintf (buf,EFCT_MAX_VERSION_INFO_LEN ,"%u" , +MCDI_DWORD (outbuf,GET_VERSION_V5_OUT_BOARD_REVISION )); +devlink_info_version_fixed_put (req,DEVLINK_INFO_VERSION_GENERIC_BOARD_REV , + buf); + } + + str =MCDI_PTR (outbuf,GET_VERSION_V5_OUT_BOARD_SERIAL ); +if (str[0 ]) +devlink_info_board_serial_number_put (req, str); + } + +if (flags &BIT (EFCT_VER_FLAG (FPGA_EXT_INFO ))) { + dwords = (__le32 *)MCDI_PTR (outbuf, +GET_VERSION_V5_OUT_FPGA_VERSION ); + offset =snprintf (buf,EFCT_MAX_VERSION_INFO_LEN ,"%u_%c%u" , +le32_to_cpu (dwords[0 ]), +'A' +le32_to_cpu (dwords[1 ]), +le32_to_cpu (dwords[2 ])); + + str =MCDI_PTR (outbuf,GET_VERSION_V5_OUT_FPGA_EXTRA ); +if (str[0 ]) +snprintf (&buf[offset],EFCT_MAX_VERSION_INFO_LEN - offset, +" (%s)" , str); + +devlink_info_version_running_put (req,EFCT_DEVLINK_INFO_VERSION_FPGA_REV , buf); + } + +if (flags &BIT (EFCT_VER_FLAG (CMC_EXT_INFO ))) { + dwords = (__le32 *)MCDI_PTR (outbuf,GET_VERSION_V5_OUT_CMCFW_VERSION ); + offset =snprintf (buf,EFCT_MAX_VERSION_INFO_LEN ,"%u.%u.%u.%u" , +le32_to_cpu (dwords[0 ]), +le32_to_cpu (dwords[1 ]), +le32_to_cpu (dwords[2 ]), +le32_to_cpu (dwords[3 ])); + + tstamp =MCDI_QWORD (outbuf,GET_VERSION_V5_OUT_CMCFW_BUILD_DATE ); +if (tstamp) { +rtc_time64_to_tm (tstamp, &build_date); +snprintf (&buf[offset],EFCT_MAX_VERSION_INFO_LEN - offset, +" (%ptRd)" , &build_date); + } + +devlink_info_version_running_put (req,EFCT_DEVLINK_INFO_VERSION_FW_MGMT_CMC , buf); + } + + words = (__le16 *)MCDI_PTR (outbuf,GET_VERSION_V5_OUT_VERSION ); + offset =snprintf (buf,EFCT_MAX_VERSION_INFO_LEN ,"%u.%u.%u.%u" , +le16_to_cpu (words[0 ]),le16_to_cpu (words[1 ]), +le16_to_cpu (words[2 ]),le16_to_cpu (words[3 ])); +if (flags &BIT (EFCT_VER_FLAG (MCFW_EXT_INFO ))) { + build_id =MCDI_DWORD (outbuf,GET_VERSION_V5_OUT_MCFW_BUILD_ID ); +snprintf (&buf[offset],EFCT_MAX_VERSION_INFO_LEN - offset, +" (%x) %s" , build_id, +MCDI_PTR (outbuf,GET_VERSION_V5_OUT_MCFW_BUILD_NAME )); + } +devlink_info_version_running_put (req,DEVLINK_INFO_VERSION_GENERIC_FW_MGMT , buf); + +if (flags &BIT (EFCT_VER_FLAG (SUCFW_EXT_INFO ))) { + dwords = (__le32 *)MCDI_PTR (outbuf,GET_VERSION_V5_OUT_SUCFW_VERSION ); + tstamp =MCDI_QWORD (outbuf,GET_VERSION_V5_OUT_SUCFW_BUILD_DATE ); +rtc_time64_to_tm (tstamp, &build_date); + build_id =MCDI_DWORD (outbuf,GET_VERSION_V5_OUT_SUCFW_CHIP_ID ); + +snprintf (buf,EFCT_MAX_VERSION_INFO_LEN , +"%u.%u.%u.%u type %x (%ptRd)" , +le32_to_cpu (dwords[0 ]),le32_to_cpu (dwords[1 ]), +le32_to_cpu (dwords[2 ]),le32_to_cpu (dwords[3 ]), + build_id, &build_date); + +devlink_info_version_running_put (req,EFCT_DEVLINK_INFO_VERSION_FW_MGMT_SUC , buf); + } + +if (flags &BIT (EFCT_VER_FLAG (DATAPATH_HW_VERSION ))) { + dwords = (__le32 *)MCDI_PTR (outbuf,GET_VERSION_V5_OUT_DATAPATH_HW_VERSION ); + +snprintf (buf,EFCT_MAX_VERSION_INFO_LEN ,"%u.%u.%u" , +le32_to_cpu (dwords[0 ]),le32_to_cpu (dwords[1 ]), +le32_to_cpu (dwords[2 ])); + +devlink_info_version_running_put (req,EFCT_DEVLINK_INFO_VERSION_DATAPATH_HW , buf); + } + +if (flags &BIT (EFCT_VER_FLAG (DATAPATH_FW_VERSION ))) { + dwords = (__le32 *)MCDI_PTR (outbuf,GET_VERSION_V5_OUT_DATAPATH_FW_VERSION ); + +snprintf (buf,EFCT_MAX_VERSION_INFO_LEN ,"%u.%u.%u" , +le32_to_cpu (dwords[0 ]),le32_to_cpu (dwords[1 ]), +le32_to_cpu (dwords[2 ])); + +devlink_info_version_running_put (req,EFCT_DEVLINK_INFO_VERSION_DATAPATH_FW , + buf); + } + +if (flags &BIT (EFCT_VER_FLAG (SOC_BOOT_VERSION ))) { + dwords = (__le32 *)MCDI_PTR (outbuf,GET_VERSION_V5_OUT_SOC_BOOT_VERSION ); + +snprintf (buf,EFCT_MAX_VERSION_INFO_LEN ,"%u.%u.%u.%u" , +le32_to_cpu (dwords[0 ]),le32_to_cpu (dwords[1 ]), +le32_to_cpu (dwords[2 ]), +le32_to_cpu (dwords[3 ])); + +devlink_info_version_running_put (req,EFCT_DEVLINK_INFO_VERSION_SOC_BOOT , buf); + } + +if (flags &BIT (EFCT_VER_FLAG (SOC_UBOOT_VERSION ))) { + dwords = (__le32 *)MCDI_PTR (outbuf,GET_VERSION_V5_OUT_SOC_UBOOT_VERSION ); + +snprintf (buf,EFCT_MAX_VERSION_INFO_LEN ,"%u.%u.%u.%u" , +le32_to_cpu (dwords[0 ]),le32_to_cpu (dwords[1 ]), +le32_to_cpu (dwords[2 ]), +le32_to_cpu (dwords[3 ])); + +devlink_info_version_running_put (req,EFCT_DEVLINK_INFO_VERSION_SOC_UBOOT , buf); + } + +if (flags &BIT (EFCT_VER_FLAG (SOC_MAIN_ROOTFS_VERSION ))) { + dwords = (__le32 *)MCDI_PTR (outbuf,GET_VERSION_V5_OUT_SOC_MAIN_ROOTFS_VERSION ); + +snprintf (buf,EFCT_MAX_VERSION_INFO_LEN ,"%u.%u.%u.%u" , +le32_to_cpu (dwords[0 ]),le32_to_cpu (dwords[1 ]), +le32_to_cpu (dwords[2 ]), +le32_to_cpu (dwords[3 ])); + +devlink_info_version_running_put (req,EFCT_DEVLINK_INFO_VERSION_SOC_MAIN , buf); + } + +if (flags &BIT (EFCT_VER_FLAG (SOC_RECOVERY_BUILDROOT_VERSION ))) { + dwords = (__le32 *)MCDI_PTR (outbuf, +GET_VERSION_V5_OUT_SOC_RECOVERY_BUILDROOT_VERSION ); + +snprintf (buf,EFCT_MAX_VERSION_INFO_LEN ,"%u.%u.%u.%u" , +le32_to_cpu (dwords[0 ]),le32_to_cpu (dwords[1 ]), +le32_to_cpu (dwords[2 ]), +le32_to_cpu (dwords[3 ])); + +devlink_info_version_running_put (req,EFCT_DEVLINK_INFO_VERSION_SOC_RECOVERY , buf); + } + +if (flags &BIT (EFCT_VER_FLAG (SUCFW_VERSION )) && + ~flags &BIT (EFCT_VER_FLAG (SUCFW_EXT_INFO ))) { + dwords = (__le32 *)MCDI_PTR (outbuf,GET_VERSION_V5_OUT_SUCFW_VERSION ); +snprintf (buf,EFCT_MAX_VERSION_INFO_LEN ,"%u.%u.%u.%u" , +le32_to_cpu (dwords[0 ]),le32_to_cpu (dwords[1 ]), +le32_to_cpu (dwords[2 ]), +le32_to_cpu (dwords[3 ])); +devlink_info_version_running_put (req,EFCT_DEVLINK_INFO_VERSION_FW_MGMT_SUC , buf); + } + +if (flags &BIT (EFCT_VER_FLAG (BOARD_VERSION ))) { + dwords = (__le32 *)MCDI_PTR (outbuf,GET_VERSION_V5_OUT_BOARD_VERSION ); + +snprintf (buf,EFCT_MAX_VERSION_INFO_LEN ,"%u.%u.%u.%u" , +le32_to_cpu (dwords[0 ]),le32_to_cpu (dwords[1 ]), +le32_to_cpu (dwords[2 ]), +le32_to_cpu (dwords[3 ])); + +devlink_info_version_running_put (req,DEVLINK_INFO_VERSION_GENERIC_BOARD_REV , buf); + } + +if (flags &BIT (EFCT_VER_FLAG (BUNDLE_VERSION ))) { + dwords = (__le32 *)MCDI_PTR (outbuf,GET_VERSION_V5_OUT_BUNDLE_VERSION ); + +snprintf (buf,EFCT_MAX_VERSION_INFO_LEN ,"%u.%u.%u.%u" , +le32_to_cpu (dwords[0 ]),le32_to_cpu (dwords[1 ]), +le32_to_cpu (dwords[2 ]), +le32_to_cpu (dwords[3 ])); + +devlink_info_version_running_put (req,DEVLINK_INFO_VERSION_GENERIC_FW_BUNDLE_ID , + buf); + } +} + +#undef EFCT_VER_FLAG + +static void efct_devlink_info_query_all (struct efct_nic *efct, +struct devlink_info_req *req) +{ +efct_devlink_info_board_cfg (efct, req); +efct_devlink_info_stored_versions (efct, req); +efct_devlink_info_running_versions (efct, req); +} + +enum efct_devlink_param_id { +EFCT_DEVLINK_PARAM_ID_BASE =DEVLINK_PARAM_GENERIC_ID_MAX , +EFCT_DEVLINK_PARAM_ID_CT_THRESH , +EFCT_DEVLINK_PARAM_ID_DIST_LAYOUT , +EFCT_DEVLINK_PARAM_ID_SEPARATED_CPU , +EFCT_DEVLINK_PARAM_ID_IRQ_ADAPT_LOW_THRESH , +EFCT_DEVLINK_PARAM_ID_IRQ_ADAPT_HIGH_THRESH , +EFCT_DEVLINK_PARAM_ID_IRQ_ADAPT_IRQS , +EFCT_DEVLINK_PARAM_ID_RX_MERGE_TIMEOUT_NS , +EFCT_DEVLINK_PARAM_ID_TX_MERGE_TIMEOUT_NS , +}; + +static int efct_irq_adapt_low_thresh_param_get (struct devlink *dl,u32 id, +struct devlink_param_gset_ctx *ctx) +{ +struct efct_device **efct_dev =devlink_priv (dl); +struct efct_nic *efct = (*efct_dev)->efct[0 ]; + + ctx->val.vu32 = efct->evq[0 ].irq_adapt_low_thresh; + +return 0 ; +} + +static int efct_irq_adapt_low_thresh_param_set (struct devlink *dl,u32 id, +struct devlink_param_gset_ctx *ctx) +{ +struct efct_device **efct_dev =devlink_priv (dl); +struct efct_nic *efct; +int i, j; + +for (i =0 ; i < (*efct_dev)->num_ports; i++) { + efct = (*efct_dev)->efct[i]; +for (j =0 ; j < efct->max_evq_count; j++) + efct->evq[j].irq_adapt_low_thresh = ctx->val.vu32; + } +return 0 ; +} + +static int efct_irq_adapt_high_thresh_param_get (struct devlink *dl,u32 id, +struct devlink_param_gset_ctx *ctx) +{ +struct efct_device **efct_dev =devlink_priv (dl); +struct efct_nic *efct = (*efct_dev)->efct[0 ]; + + ctx->val.vu32 = efct->evq[0 ].irq_adapt_high_thresh; + +return 0 ; +} + +static int efct_irq_adapt_high_thresh_param_set (struct devlink *dl,u32 id, +struct devlink_param_gset_ctx *ctx) +{ +struct efct_device **efct_dev =devlink_priv (dl); +struct efct_nic *efct; +int i, j; + +for (i =0 ; i < (*efct_dev)->num_ports; i++) { + efct = (*efct_dev)->efct[i]; +for (j =0 ; j < efct->max_evq_count; j++) + efct->evq[j].irq_adapt_high_thresh = ctx->val.vu32; + } +return 0 ; +} + +static int efct_irq_adapt_irqs_param_get (struct devlink *dl,u32 id, +struct devlink_param_gset_ctx *ctx) +{ +struct efct_device **efct_dev =devlink_priv (dl); +struct efct_nic *efct = (*efct_dev)->efct[0 ]; + + ctx->val.vu32 = efct->evq[0 ].irq_adapt_irqs; + +return 0 ; +} + +static int efct_irq_adapt_irqs_param_set (struct devlink *dl,u32 id, +struct devlink_param_gset_ctx *ctx) +{ +struct efct_device **efct_dev =devlink_priv (dl); +struct efct_nic *efct; +int i, j; + +for (i =0 ; i < (*efct_dev)->num_ports; i++) { + efct = (*efct_dev)->efct[i]; +for (j =0 ; j < efct->max_evq_count; j++) + efct->evq[j].irq_adapt_irqs = ctx->val.vu32; + } +return 0 ; +} + +static int efct_rx_merge_timeout_get (struct devlink *dl,u32 id, +struct devlink_param_gset_ctx *ctx) +{ +struct efct_device **efct_dev =devlink_priv (dl); +struct efct_nic *efct = (*efct_dev)->efct[0 ]; + + ctx->val.vu32 = efct->evq[0 ].rx_merge_timeout_ns; + +return 0 ; +} + +static int efct_rx_merge_timeout_set (struct devlink *dl,u32 id, +struct devlink_param_gset_ctx *ctx) +{ +struct efct_device **efct_dev =devlink_priv (dl); +struct efct_nic *efct; +int i, j; + +for (i =0 ; i < (*efct_dev)->num_ports; i++) { + efct = (*efct_dev)->efct[i]; +for (j =0 ; j < efct->max_evq_count; j++) + efct->evq[j].rx_merge_timeout_ns = ctx->val.vu32; + } +return 0 ; +} + +static int efct_rx_merge_timeout_validate (struct devlink *dl,u32 id,union devlink_param_value val, +struct netlink_ext_ack *extack) +{ +if (val.vu32 >MAX_RX_MERGE_TIMEOUT_NS_VALUE ) { +pr_info ("Receive event merge timeout too large for X3, It shall be less than %u\n" , +MAX_RX_MERGE_TIMEOUT_NS_VALUE ); +return -EINVAL ; + } + +if (val.vu32 >0 && (val.vu32 %EV_TIMER_GRANULARITY_NS !=0 )) { +pr_info ("Receive event merge timeout must be a multiple of %u\n" , +EV_TIMER_GRANULARITY_NS ); +return -EINVAL ; + } + +return 0 ; +} + +static int efct_tx_merge_timeout_get (struct devlink *dl,u32 id,struct devlink_param_gset_ctx *ctx) +{ +struct efct_device **efct_dev =devlink_priv (dl); +struct efct_nic *efct = (*efct_dev)->efct[0 ]; + + ctx->val.vu32 = efct->evq[0 ].tx_merge_timeout_ns; + +return 0 ; +} + +static int efct_tx_merge_timeout_set (struct devlink *dl,u32 id,struct devlink_param_gset_ctx *ctx) +{ +struct efct_device **efct_dev =devlink_priv (dl); +struct efct_nic *efct; +int i, j; + +for (i =0 ; i < (*efct_dev)->num_ports; i++) { + efct = (*efct_dev)->efct[i]; +for (j =0 ; j < efct->max_evq_count; j++) + efct->evq[j].tx_merge_timeout_ns = ctx->val.vu32; + } +return 0 ; +} + +static int efct_tx_merge_timeout_validate (struct devlink *dl,u32 id,union devlink_param_value val, +struct netlink_ext_ack *extack) +{ +if (val.vu32 >MAX_TX_MERGE_TIMEOUT_NS_VALUE ) { +pr_info ("Transmit event merge timeout too large for X3, It shall be less than %u\n" , +MAX_TX_MERGE_TIMEOUT_NS_VALUE ); +return -EINVAL ; + } + +if (val.vu32 >0 && (val.vu32 %EV_TIMER_GRANULARITY_NS !=0 )) { +pr_info ("Transmit event merge timeout must be a multiple of %u\n" , +EV_TIMER_GRANULARITY_NS ); +return -EINVAL ; + } + +return 0 ; +} + +static int efct_ct_thresh_param_get (struct devlink *dl,u32 id,struct devlink_param_gset_ctx *ctx) +{ +struct efct_device **efct_dev =devlink_priv (dl); +struct efct_nic *efct = (*efct_dev)->efct[0 ]; + + ctx->val.vu16 = efct->ct_thresh *64 ; + +return 0 ; +} + +static int efct_ct_thresh_param_set (struct devlink *dl,u32 id,struct devlink_param_gset_ctx *ctx) +{ +struct efct_device **efct_dev =devlink_priv (dl); +struct efct_nic *efct; +int i, j; + +for (i =0 ; i < (*efct_dev)->num_ports; i++) { + efct = (*efct_dev)->efct[i]; + efct->ct_thresh = ctx->val.vu16 /64 ; +for (j =0 ; j <EFCT_MAX_CORE_TX_QUEUES ; j++) + efct->txq[j].ct_thresh = efct->ct_thresh; + } +return 0 ; +} + +static int efct_ct_thresh_param_validate (struct devlink *dl,u32 id,union devlink_param_value val, +struct netlink_ext_ack *extack) +{ +if (((val.vu16 %64 ) !=0 ) || val.vu16 >MAX_CT_THRESHOLD_VALUE ) { +pr_info ("Invalid CTPIO Threshold value passed. It shall be less than %d and a multiple of 64" , +MAX_CT_THRESHOLD_VALUE ); +return -EINVAL ; + } + +return 0 ; +} + +static int efct_dist_layout_param_get (struct devlink *dl,u32 id, +struct devlink_param_gset_ctx *ctx) +{ +struct efct_device **efct_dev =devlink_priv (dl); + + ctx->val.vu8 = (*efct_dev)->dist_layout; + +return 0 ; +} + +static int efct_dist_layout_param_set (struct devlink *dl,u32 id, +struct devlink_param_gset_ctx *ctx) +{ +struct efct_device **efct_dev =devlink_priv (dl); +struct efct_nic *efct; +int i; + +if ((*efct_dev)->dist_layout == ctx->val.vu8) +return 0 ; + + (*efct_dev)->dist_layout = ctx->val.vu8; +for (i =0 ; i < (*efct_dev)->num_ports; i++) { + efct = (*efct_dev)->efct[i]; +mutex_lock (&efct->state_lock); +if (efct->state ==STATE_NET_UP ) +efct_set_interrupt_affinity (efct); +mutex_unlock (&efct->state_lock); + } + +return 0 ; +} + +static int efct_dist_layout_param_validate (struct devlink *dl,u32 id, +union devlink_param_value val, +struct netlink_ext_ack *extack) +{ +if (val.vu8 !=RX_LAYOUT_DISTRIBUTED && val.vu8 !=RX_LAYOUT_SEPARATED ) { +NL_SET_ERR_MSG_MOD (extack,"Invalid Layout value.Use 0-Distributed,1-Separated" ); +return -EINVAL ; + } + +return 0 ; +} + +static int efct_separated_cpu_param_get (struct devlink *dl,u32 id, +struct devlink_param_gset_ctx *ctx) +{ +struct efct_device **efct_dev =devlink_priv (dl); + + ctx->val.vu8 = (*efct_dev)->separated_rx_cpu; + +return 0 ; +} + +static int efct_separated_cpu_param_set (struct devlink *dl,u32 id, +struct devlink_param_gset_ctx *ctx) +{ +struct efct_device **efct_dev =devlink_priv (dl); +struct efct_nic *efct; +int i; + +if ((*efct_dev)->separated_rx_cpu == ctx->val.vu8) +return 0 ; + + (*efct_dev)->separated_rx_cpu = ctx->val.vu8; +for (i =0 ; i < (*efct_dev)->num_ports; i++) { + efct = (*efct_dev)->efct[i]; +mutex_lock (&efct->state_lock); +if (efct->state ==STATE_NET_UP ) +efct_set_interrupt_affinity (efct); +mutex_unlock (&efct->state_lock); + } + +return 0 ; +} + +static int efct_separated_cpu_param_validate (struct devlink *dl,u32 id, +union devlink_param_value val, +struct netlink_ext_ack *extack) +{ +struct efct_device **efct_dev =devlink_priv (dl); + +if ((*efct_dev)->dist_layout ==RX_LAYOUT_DISTRIBUTED ) { +NL_SET_ERR_MSG_MOD (extack,"Current layout is distributed. Use separated layout" ); +return -EINVAL ; + } + +if (val.vu8 >num_online_cpus ()) { +NL_SET_ERR_MSG_MOD (extack, +"Invalid CPU value passed. Value exceeds current online CPUS" ); +pr_info ("Invalid CPU value. Exceeds current online CPUS [%u]" ,num_online_cpus ()); +return -EINVAL ; + } + +return 0 ; +} + +static const struct devlink_param efct_devlink_params[] = { +DEVLINK_PARAM_DRIVER (EFCT_DEVLINK_PARAM_ID_CT_THRESH , +"ct_thresh" ,DEVLINK_PARAM_TYPE_U16 , +BIT (DEVLINK_PARAM_CMODE_RUNTIME ), + efct_ct_thresh_param_get, + efct_ct_thresh_param_set, + efct_ct_thresh_param_validate), +DEVLINK_PARAM_DRIVER (EFCT_DEVLINK_PARAM_ID_DIST_LAYOUT , +"dist_layout" ,DEVLINK_PARAM_TYPE_U8 , +BIT (DEVLINK_PARAM_CMODE_RUNTIME ), + efct_dist_layout_param_get, + efct_dist_layout_param_set, + efct_dist_layout_param_validate), +DEVLINK_PARAM_DRIVER (EFCT_DEVLINK_PARAM_ID_SEPARATED_CPU , +"separated_cpu" ,DEVLINK_PARAM_TYPE_U8 , +BIT (DEVLINK_PARAM_CMODE_RUNTIME ), + efct_separated_cpu_param_get, + efct_separated_cpu_param_set, + efct_separated_cpu_param_validate), +DEVLINK_PARAM_DRIVER (EFCT_DEVLINK_PARAM_ID_IRQ_ADAPT_LOW_THRESH , +"irq_adapt_low_thresh" ,DEVLINK_PARAM_TYPE_U32 , +BIT (DEVLINK_PARAM_CMODE_RUNTIME ), + efct_irq_adapt_low_thresh_param_get, + efct_irq_adapt_low_thresh_param_set, +NULL ), +DEVLINK_PARAM_DRIVER (EFCT_DEVLINK_PARAM_ID_IRQ_ADAPT_HIGH_THRESH , +"irq_adapt_high_thresh" ,DEVLINK_PARAM_TYPE_U32 , +BIT (DEVLINK_PARAM_CMODE_RUNTIME ), + efct_irq_adapt_high_thresh_param_get, + efct_irq_adapt_high_thresh_param_set, +NULL ), +DEVLINK_PARAM_DRIVER (EFCT_DEVLINK_PARAM_ID_IRQ_ADAPT_IRQS , +"irq_adapt_irqs" ,DEVLINK_PARAM_TYPE_U32 , +BIT (DEVLINK_PARAM_CMODE_RUNTIME ), + efct_irq_adapt_irqs_param_get, + efct_irq_adapt_irqs_param_set, +NULL ), +DEVLINK_PARAM_DRIVER (EFCT_DEVLINK_PARAM_ID_RX_MERGE_TIMEOUT_NS , +"rx_merge_timeout" ,DEVLINK_PARAM_TYPE_U32 , +BIT (DEVLINK_PARAM_CMODE_RUNTIME ), + efct_rx_merge_timeout_get, + efct_rx_merge_timeout_set, + efct_rx_merge_timeout_validate), +DEVLINK_PARAM_DRIVER (EFCT_DEVLINK_PARAM_ID_TX_MERGE_TIMEOUT_NS , +"tx_merge_timeout" ,DEVLINK_PARAM_TYPE_U32 , +BIT (DEVLINK_PARAM_CMODE_RUNTIME ), + efct_tx_merge_timeout_get, + efct_tx_merge_timeout_set, + efct_tx_merge_timeout_validate), +}; + +static int efct_devlink_info_get (struct devlink *devlink, +struct devlink_info_req *req, +struct netlink_ext_ack *extack) +{ +struct efct_device **efct_dev =devlink_priv (devlink); +struct efct_nic *efct = (*efct_dev)->efct[0 ]; + +efct_devlink_info_query_all (efct, req); +return 0 ; +} + +static int efct_devlink_flash_update (struct devlink *devlink, +struct devlink_flash_update_params *params, +struct netlink_ext_ack *extack) +{ +struct efct_device **efct_dev =devlink_priv (devlink); +struct efct_nic *efct = (*efct_dev)->efct[0 ]; + +return efct_reflash_flash_firmware (efct, params->fw); +} + +static const struct devlink_ops efct_devlink_ops = { + .supported_flash_update_params =0 , + .flash_update = efct_devlink_flash_update, + .info_get = efct_devlink_info_get, +}; + +static void efct_devlink_params_unregister (struct efct_device *efct_dev) +{ +if (efct_dev->devlink) { +devlink_params_unregister (efct_dev->devlink, efct_devlink_params, +ARRAY_SIZE (efct_devlink_params)); + } +} + +void efct_fini_devlink (struct efct_device *efct_dev) +{ +if (efct_dev->devlink) +devlink_free (efct_dev->devlink); + efct_dev->devlink =NULL ; +} + +int efct_probe_devlink (struct efct_device *efct_dev) +{ +struct efct_device **devlink_private; + +int rc =0 ; + + efct_dev->devlink =devlink_alloc (&efct_devlink_ops, +sizeof (struct efct_device **), + &efct_dev->pci_dev->dev); +if (!efct_dev->devlink) +return -ENOMEM ; + + devlink_private =devlink_priv (efct_dev->devlink); + *devlink_private = efct_dev; + +return rc; +} + +int efct_devlink_port_register (struct efct_nic *efct) +{ +struct devlink_port_attrs attrs = {}; +int rc; + + attrs.flavour =DEVLINK_PORT_FLAVOUR_PHYSICAL ; + attrs.phys.port_number = efct->port_num; +devlink_port_attrs_set (&efct->dl_port, &attrs); +SET_NETDEV_DEVLINK_PORT (efct->net_dev, &efct->dl_port); + rc =devlink_port_register (efct->efct_dev->devlink, &efct->dl_port, + efct->port_num); +if (rc) +return rc; + +return 0 ; +} + +static int efct_devlink_params_register (struct efct_device *efct_dev) +{ +int rc; + + rc =devlink_params_register (efct_dev->devlink, efct_devlink_params, +ARRAY_SIZE (efct_devlink_params)); +if (rc) +return rc; + +return 0 ; +} + +int efct_devlink_register (struct efct_device *efct_dev) +{ +int rc =0 ; + + rc =efct_devlink_params_register (efct_dev); +if (rc) +return rc; + +devlink_register (efct_dev->devlink); + +return rc; +} + +void efct_devlink_unregister (struct efct_device *efct_dev) +{ +devlink_unregister (efct_dev->devlink); +efct_devlink_params_unregister (efct_dev); +}
drivers/net/ethernet/amd/efct/efct_devlink.h new file +21 -0
@@ -0,0 +1,21 @@ +/* SPDX-License-Identifier: GPL-2.0 +**************************************************************************** +* Driver for AMD/Xilinx network controllers and boards +* Copyright (C) 2021, Xilinx, Inc. +* Copyright (C) 2022-2023, Advanced Micro Devices, Inc. +*/ +#ifndef _EFCT_DEVLINK_H +#define _EFCT_DEVLINK_H + +#include "efct_driver.h" +#include <net/devlink.h> + +int efct_probe_devlink (struct efct_device *efct_dev); +int efct_devlink_port_register (struct efct_nic *efct); +void efct_fini_devlink (struct efct_device *efct_dev); +int efct_devlink_register (struct efct_device *efct_dev); +void efct_devlink_unregister (struct efct_device *efct_dev); + +struct devlink_port *efct_get_devlink_port (struct net_device *dev); + +#endif /* _EFCT_DEVLINK_H */
drivers/net/ethernet/amd/efct/efct_driver.h +3 -0
@@ -20,6 +20,7 @@#include <linux/netdevice.h> #include <linux/pci.h> +#include <net/devlink.h> #include "efct_enum.h" #include "efct_bitfield.h"
@@ -585,6 +586,7 @@ struct efct_nic {/* Mutex for serializing firmware reflash operations.*/ struct mutex reflash_mutex;struct efct_mcdi_filter_table *filter_table; +struct devlink_port dl_port; };struct design_params {
@@ -644,6 +646,7 @@ struct efct_device {resource_size_t bar_len;bool mcdi_logging;struct efct_nic *efct[MAX_PORTS ]; +void *devlink;/*IRQ vectors per port*/ u16 vec_per_port;struct msix_entry *xentries;
drivers/net/ethernet/amd/efct/efct_netdev.c +1 -0
@@ -11,6 +11,7 @@#include "efct_nic.h" #include "mcdi.h" #include "mcdi_port_common.h" +#include "efct_devlink.h" static int efct_netdev_event (struct notifier_block *this,unsigned long event,void *ptr)
drivers/net/ethernet/amd/efct/efct_pci.c +23 -1
@@ -14,6 +14,7 @@#include "efct_common.h" #include "efct_netdev.h" #include "efct_nic.h" +#include "efct_devlink.h" /************************************************************************** *
@@ -664,6 +665,7 @@ static u32 efct_get_num_ports(struct efct_device *efct_dev)static void efct_free_dev (struct efct_nic *efct) {efct_unregister_netdev (efct); +devlink_port_unregister (&efct->dl_port); efct->type->remove (efct);efct_unmap_membase (efct);free_netdev (efct->net_dev);
@@ -907,6 +909,9 @@ static int efct_pci_probe rc =efct_alloc_msix (efct_dev);if (rc) goto fail2; + rc =efct_probe_devlink (efct_dev); +if (rc) + goto free_msi;efct_nic_check_pcie_link (efct_dev,EFCT_BW_PCIE_GEN3_X8 ,NULL ,NULL );for (i =0 ; i < efct_dev->num_ports; i++) {
@@ -957,6 +962,12 @@ static int efct_pci_probepci_err (pci_dev,"Unable to probe net device, rc=%d\n" , rc); goto fail6; } +/*Devlink port register*/ + rc =efct_devlink_port_register (efct); +if (rc) { +pci_err (pci_dev,"Unable to register devlink port, rc=%d\n" , rc); + goto fail6; + } rc =efct_register_netdev (efct);if (rc) {pci_err (pci_dev,"Unable to register net device, rc=%d\n" , rc);
@@ -965,9 +976,14 @@ static int efct_pci_probe/*Populating IRQ numbers in aux resources*/ efct_assign_msix (efct, i); } - rc =efct_init_stats_wq (efct_dev); + rc =efct_devlink_register (efct_dev);if (rc) goto freep0; + rc =efct_init_stats_wq (efct_dev); +if (rc) { +efct_devlink_unregister (efct_dev); + goto freep0; + } pr_info("EFCT X3 NIC detected: device %04x:%04x subsys %04x:%04x\n", pci_dev->vendor, pci_dev->device,
@@ -976,6 +992,7 @@ static int efct_pci_probereturn 0 ; fail7: +devlink_port_unregister (&efct->dl_port); fail6: efct->type->remove (efct); fail5:
@@ -987,6 +1004,8 @@ static int efct_pci_probe freep0:for (j =0 ; j < i ; j++)efct_free_dev (efct_dev->efct[j]); +efct_fini_devlink (efct_dev); +free_msi:efct_free_msix (efct_dev); fail2: #ifdef CONFIG_EFCT_MCDI_LOGGING
@@ -1015,14 +1034,17 @@ static void efct_pci_remove(struct pci_dev *pci_dev)return ;efct_fini_stats_wq (efct_dev); +efct_devlink_unregister (efct_dev);for (i =0 ; i < efct_dev->num_ports; i++) {efct_close_netdev (efct_dev->efct[i]);efct_remove_netdev (efct_dev->efct[i]); +devlink_port_unregister (&efct_dev->efct[i]->dl_port); efct_dev->efct[i]->type->remove (efct_dev->efct[i]);efct_flush_reset_workqueue ();efct_unmap_membase (efct_dev->efct[i]);free_netdev (efct_dev->efct[i]->net_dev); } +efct_fini_devlink (efct_dev);efct_free_msix (efct_dev);#ifdef CONFIG_EFCT_MCDI_LOGGING efct_fini_mcdi_logging (efct_dev);
drivers/net/ethernet/amd/efct/efct_reflash.c new file +564 -0
564 lines not on this page · raw message
drivers/net/ethernet/amd/efct/efct_reflash.h new file +16 -0
@@ -0,0 +1,16 @@ +/* SPDX-License-Identifier: GPL-2.0 +**************************************************************************** +* Driver for AMD/Xilinx network controllers and boards +* Copyright (C) 2021, Xilinx, Inc. +* Copyright (C) 2022-2023, Advanced Micro Devices, Inc. +*/ + +#ifndef _EFCT_REFLASH_H +#define _EFCT_REFLASH_H + +#include "efct_driver.h" +#include <linux/firmware.h> + +int efct_reflash_flash_firmware (struct efct_nic *efct,const struct firmware *fw); + +#endif /* _EFCT_REFLASH_H */
Signature · 1 line
2.25.1
PATCH 4/6 net: ethernet: efct: Add Hardware timestamp support
In reply to Harsh JainAdd support for
- packet timestamping in Tx/Rx.
- PTP clock support
- Periodic PPS signal output
--- drivers/net/ethernet/amd/efct/efct_driver.h | 15 + drivers/net/ethernet/amd/efct/efct_netdev.c | 24 + drivers/net/ethernet/amd/efct/efct_nic.c | 61 + drivers/net/ethernet/amd/efct/efct_ptp.c | 1481 +++++++++++++++++++ drivers/net/ethernet/amd/efct/efct_ptp.h | 186 +++ drivers/net/ethernet/amd/efct/efct_rx.c | 35 + drivers/net/ethernet/amd/efct/efct_tx.c | 17 + drivers/net/ethernet/amd/efct/mcdi.c | 9 + 8 files changed, 1828 insertions(+) create mode 100644 drivers/net/ethernet/amd/efct/efct_ptp.c create mode 100644 drivers/net/ethernet/amd/efct/efct_ptp.h
drivers/net/ethernet/amd/efct/efct_driver.h +15 -0
@@ -37,6 +37,9 @@* Efx data structures * **************************************************************************/ +#ifdef CONFIG_EFCT_PTP +struct efct_ptp_data ; +#endif #define EFCT_MAX_RX_QUEUES 16#define EFCT_MAX_TX_QUEUES 32#define EFCT_MAX_EV_QUEUES 48
@@ -451,6 +454,10 @@ struct efct_ev_queue {unsigned char queue_count;/* Associated queue */ void *queue; +#ifdef CONFIG_EFCT_PTP +u64 sync_timestamp_major; +enum efct_sync_events_state sync_events_state; +#endif /* Number of IRQs since last adaptive moderation decision */ u32 irq_count;/* IRQ moderation score */
@@ -486,6 +493,10 @@ struct efct_nic {struct net_device *net_dev;void *nic_data;void *phy_data; +#ifdef CONFIG_EFCT_PTP +struct efct_ptp_data *ptp_data; +struct efct_ptp_data *phc_ptp_data; +#endif enum efct_phy_mode phy_mode;bool phy_power_force_off;enum efct_loopback_mode loopback_mode;
@@ -745,6 +756,10 @@ struct efct_nic_type {irqreturn_t (*irq_handle_msix)(int irq,void *dev_id);u32 (*check_caps)(const struct efct_nic *efct,u8 flag,u32 offset);bool (*has_dynamic_sensors)(struct efct_nic *efct); +#ifdef CONFIG_EFCT_PTP +int (*ptp_set_ts_config)(struct efct_nic *efct,struct hwtstamp_config *init); +u32 hwtstamp_filters; +#endif int (*get_phys_port_id)(struct efct_nic *efct,struct netdev_phys_item_id *ppid);int (*irq_test_generate)(struct efct_nic *efct);void (*ev_test_generate)(struct efct_ev_queue *evq);
drivers/net/ethernet/amd/efct/efct_netdev.c +24 -0
@@ -12,6 +12,9 @@#include "mcdi.h" #include "mcdi_port_common.h" #include "efct_devlink.h" +#ifdef CONFIG_EFCT_PTP +#include "efct_ptp.h" +#endif static int efct_netdev_event (struct notifier_block *this,unsigned long event,void *ptr)
@@ -110,6 +113,10 @@ static void efct_stop_all_queues(struct efct_nic *efct)continue ; efct->type->ev_purge (&efct->evq[i]); } +#ifdef CONFIG_EFCT_PTP +for_each_set_bit (i, &efct->evq_active_mask, efct->max_evq_count) + efct->evq[i].sync_events_state =SYNC_EVENTS_DISABLED ; +#endif return ; }
@@ -165,6 +172,9 @@ static int efct_net_open(struct net_device *net_dev)if (rc) goto fail; +#ifdef CONFIG_EFCT_PTP +efct_ptp_evt_data_init (efct); +#endif rc =efct_start_all_queues (efct);if (rc) {netif_err (efct, drv, efct->net_dev,"efct_start_all_queues failed, index %d\n" , rc);
@@ -189,6 +199,10 @@ static int efct_net_open(struct net_device *net_dev)netif_start_queue (net_dev); efct->state =STATE_NET_UP ;mutex_unlock (&efct->state_lock); +#ifdef CONFIG_EFCT_PTP +if (efct->ptp_data->txtstamp) +efct_ptp_tx_ts_event (efct, true); +#endif return 0 ;
@@ -206,6 +220,10 @@ static int efct_net_stop(struct net_device *net_dev) {struct efct_nic *efct =efct_netdev_priv (net_dev); +#ifdef CONFIG_EFCT_PTP +if (efct->ptp_data->txtstamp && !((efct->reset_pending & (1 <<RESET_TYPE_DATAPATH )))) +efct_ptp_tx_ts_event (efct, false); +#endif mutex_lock (&efct->state_lock); efct->state =STATE_NET_DOWN ;netif_stop_queue (net_dev);
@@ -300,6 +318,12 @@ static int efct_eth_ioctl(struct net_device *net_dev, struct ifreq *ifr, int cmd) {switch (cmd) { +#ifdef CONFIG_EFCT_PTP +case SIOCGHWTSTAMP : +return efct_ptp_get_ts_config (net_dev, ifr); +case SIOCSHWTSTAMP : +return efct_ptp_set_ts_config (net_dev, ifr); +#endif default :return -EOPNOTSUPP ; }
drivers/net/ethernet/amd/efct/efct_nic.c +61 -0
116 lines not on this page · raw message
drivers/net/ethernet/amd/efct/efct_ptp.c new file +1481 -0
1,481 lines not on this page · raw message
drivers/net/ethernet/amd/efct/efct_ptp.h new file +186 -0
186 lines not on this page · raw message
drivers/net/ethernet/amd/efct/efct_rx.c +35 -0
@@ -13,6 +13,9 @@#include "efct_common.h" #include "efct_reg.h" #include "efct_io.h" +#ifdef CONFIG_EFCT_PTP +#include "efct_ptp.h" +#endif /* Post buffer to NIC */ static void efct_rx_buff_post (struct efct_rx_queue *rxq,struct efct_buffer *buffer,bool rollover)
@@ -365,10 +368,35 @@ static bool check_fcs(struct efct_rx_queue *rx_queue, union efct_qword *p_meta)return 0 ; } +#ifdef CONFIG_EFCT_PTP +#define NSEC_BITS_MASK 0xffffffff + +static void efct_include_ts_in_rxskb (struct efct_rx_queue *rxq,union efct_qword *p_meta, +struct sk_buff *skb) +{ +struct skb_shared_hwtstamps *timestamps; +struct efct_ptp_data *ptp; +struct efct_nic *efct; +u64 pkt_ts_major; +u32 pkt_ts_minor; + + efct = rxq->efct; + ptp = efct->ptp_data; + timestamps =skb_hwtstamps (skb); + pkt_ts_major =EFCT_OWORD_FIELD (*((union efct_oword *)p_meta),ESF_HZ_RX_PREFIX_TIMESTAMP ); + pkt_ts_minor = (pkt_ts_major &NSEC_BITS_MASK ); + pkt_ts_major = pkt_ts_major >>32 ; + timestamps->hwtstamp = ptp->nic_to_kernel_time (pkt_ts_major, pkt_ts_minor, + ptp->ts_corrections.general_rx); +} +#endif /* Deliver packet to stack */ static void efct_rx_deliver (struct efct_rx_queue *rxq,u8 *pkt_start,union efct_qword *p_meta) {struct sk_buff *skb =NULL ; +#ifdef CONFIG_EFCT_PTP +struct efct_ptp_data *ptp; +#endif struct efct_nic *efct;struct ethhdr *eth;__wsum csum =0 ;
@@ -377,6 +405,9 @@ static void efct_rx_deliver(struct efct_rx_queue *rxq, u8 *pkt_start, union efct efct = rxq->efct; len =EFCT_QWORD_FIELD (*p_meta,ESF_HZ_RX_PREFIX_LENGTH ); +#ifdef CONFIG_EFCT_PTP + ptp = efct->ptp_data; +#endif if (unlikely (check_fcs (rxq, p_meta))) {if (!(efct->net_dev->features &NETIF_F_RXALL )) goto drop;
@@ -410,6 +441,10 @@ static void efct_rx_deliver(struct efct_rx_queue *rxq, u8 *pkt_start, union efct rxq->n_rx_alloc_skb_fail++; goto drop; } +#ifdef CONFIG_EFCT_PTP +if (ptp->rxtstamp &&EFCT_QWORD_FIELD (*p_meta,ESF_HZ_RX_PREFIX_TIMESTAMP_STATUS )) +efct_include_ts_in_rxskb (rxq, p_meta, skb); +#endif /* Copy packet from rx buffer to skb */ memcpy (skb_put (skb, len), pkt_start, len);skb_mark_napi_id (skb, &efct->evq[rxq->evq_index].napi);
drivers/net/ethernet/amd/efct/efct_tx.c +17 -0
@@ -9,6 +9,9 @@#include "efct_tx.h" #include "efct_reg.h" #include "efct_io.h" +#ifdef CONFIG_EFCT_PTP +#include "efct_ptp.h" +#endif /* Transmit header size in bytes */ #define EFCT_TX_HEADER_BYTES (ESE_HZ_XN_CTPIO_HDR_STRUCT_SIZE / 8)
@@ -200,6 +203,9 @@ static void txq_copy_skb_frags(struct efct_tx_queue *txq, struct sk_buff *skb)int efct_enqueue_skb (struct efct_tx_queue *txq,struct sk_buff *skb,struct net_device *net_dev) { +#ifdef CONFIG_EFCT_PTP +struct efct_ptp_data *ptp; +#endif bool ts = false;u64 pkt_header;int skb_len;
@@ -224,6 +230,13 @@ int efct_enqueue_skb(struct efct_tx_queue *txq, struct sk_buff *skb, struct net_txq_may_stop (txq); +#ifdef CONFIG_EFCT_PTP + ptp = txq->efct->ptp_data; +if (ptp->txtstamp &&efct_xmit_with_hwtstamp (skb)) { + ts = true; +skb_shinfo (skb)->tx_flags |=SKBTX_IN_PROGRESS ; + } +#endif pkt_header =efct_tx_pkt_header (skb_len <EFCT_MIN_FRAME_ALIGN ?EFCT_MIN_FRAME_ALIGN : skb_len, txq->ct_thresh, ts);
@@ -271,6 +284,10 @@ void _efct_ev_tx(struct efct_tx_queue *txq, u8 seq, bool __always_unused ts_statnetif_err (txq->efct, drv, txq->efct->net_dev,"Error: skb should not be null\n" );continue ; } +#ifdef CONFIG_EFCT_PTP +if (ts_status) +efct_include_ts_in_skb (txq, partial_ts, skb); +#endif pkts++; bytes += skb->len;
drivers/net/ethernet/amd/efct/mcdi.c +9 -0
@@ -12,6 +12,9 @@#include "efct_io.h" #include "mcdi.h" #include "mcdi_pcol.h" +#ifdef CONFIG_EFCT_PTP +#include "efct_ptp.h" +#endif struct efct_mcdi_copy_buffer {union efct_dword buffer[DIV_ROUND_UP (MCDI_CTL_SDU_LEN_MAX ,4 )]; };
@@ -1508,6 +1511,12 @@ bool efct_mcdi_process_event(struct efct_nic *efct,netif_info (efct, hw, efct->net_dev,"MC entered BIST mode\n" );efct_mcdi_ev_death (efct, true);return true; +#ifdef CONFIG_EFCT_PTP +case MCDI_EVENT_CODE_PTP_PPS : +case MCDI_EVENT_CODE_HW_PPS : +efct_ptp_event (efct, event); +return true; +#endif }return false;
Signature · 1 line
2.25.1
PATCH 5/6 net: ethernet: efct: Add ethtool support
In reply to Harsh JainAdd the driver interfaces required for support by the ethtool utility.
--- drivers/net/ethernet/amd/efct/efct_common.c | 160 +++ drivers/net/ethernet/amd/efct/efct_ethtool.c | 1286 ++++++++++++++++++ drivers/net/ethernet/amd/efct/efct_netdev.c | 1 + 3 files changed, 1447 insertions(+) create mode 100644 drivers/net/ethernet/amd/efct/efct_ethtool.c
drivers/net/ethernet/amd/efct/efct_common.c +160 -0
@@ -1008,6 +1008,166 @@ void efct_clear_interrupt_affinity(struct efct_nic *efct) } } +static int efct_validate_flow (struct efct_nic *efct,const struct ethtool_rx_flow_spec *rule) +{ +const struct ethtool_tcpip4_spec *ip_entry = &rule->h_u.tcp_ip4_spec; +const struct ethtool_tcpip4_spec *ip_mask = &rule->m_u.tcp_ip4_spec; +struct efct_mcdi_filter_table *table; + +/* Check that user wants us to choose the location */ +if (rule->location !=RX_CLS_LOC_ANY ) +return -EINVAL ; + +if (rule->ring_cookie >= efct->rxq_count && rule->ring_cookie !=RX_CLS_FLOW_DISC ) { +netif_err (efct, drv, efct->net_dev,"Invalid queue id %lld\n" , rule->ring_cookie); +return -EINVAL ; + } + table = efct->filter_table; +if (rule->flow_type !=TCP_V4_FLOW && rule->flow_type !=UDP_V4_FLOW ) { +netif_err (efct, drv, efct->net_dev,"Flow type %u not supported, Only IPv4 TCP/UDP is supported\n" , + rule->flow_type); + goto err; + } +if (ip_mask->psrc || ip_mask->ip4src || ip_mask->tos) { +netif_err (efct, drv, efct->net_dev,"Source IP, port, tos not supported\n" ); + goto err; + }else if ((ip_entry->ip4dst & ip_mask->ip4dst) ==MULTICAST_ADDR_START ) { +if (ip_entry->pdst) { +netif_err (efct, drv, efct->net_dev,"Destination port not supported in IP multicast\n" ); + goto err; + } +if (table->entry[EFCT_MCDI_FILTER_TBL_ROWS -1 ].spec) { +netif_err (efct, drv, efct->net_dev,"Filter already exist at Multicast location %u\n" , +EFCT_MCDI_FILTER_TBL_ROWS -1 ); +return -EBUSY ; + } + }else if (ip_mask->ip4dst !=IP4_ADDR_MASK || ip_mask->pdst !=PORT_MASK ) { +netif_err (efct, drv, efct->net_dev,"Exact match required for destination IP and port\n" ); + goto err; + } +return 0 ; +err: +return -EOPNOTSUPP ; +} + +int efct_fill_spec (struct efct_nic *efct,const struct ethtool_rx_flow_spec *rule, +struct efct_filter_spec *spec) +{ +const struct ethtool_tcpip4_spec *ip_entry = &rule->h_u.tcp_ip4_spec; +const struct ethtool_tcpip4_spec *ip_mask = &rule->m_u.tcp_ip4_spec; +struct efct_filter_spec *spec_in_table =NULL ; +struct efct_mcdi_filter_table *table; +int rc =0 , ins_index =-1 , index; +u32 flow_type; + + rc =efct_validate_flow (efct, rule); +if (rc) +return rc; + + spec->queue_id = rule->ring_cookie; + table = efct->filter_table; + flow_type = rule->flow_type; +if (ip_mask->ip4dst ==IP4_ADDR_MASK && ip_mask->pdst ==PORT_MASK ) { + spec->match_fields = + ((1 <<MC_CMD_FILTER_OP_V3_IN_MATCH_ETHER_TYPE_LBN ) | + (1 <<MC_CMD_FILTER_OP_V3_IN_MATCH_IP_PROTO_LBN )); + spec->ether_type =htons (ETH_P_IP ); + spec->ip_proto = (flow_type ==TCP_V4_FLOW ?IPPROTO_TCP + :IPPROTO_UDP ); + spec->match_fields |= + (1 <<MC_CMD_FILTER_OP_V3_IN_MATCH_DST_IP_LBN ); + spec->dst_ip = ip_entry->ip4dst; + spec->match_fields |= + (1 <<MC_CMD_FILTER_OP_V3_IN_MATCH_DST_PORT_LBN ); + spec->dst_port = ip_entry->pdst; + }else if ((ip_entry->ip4dst & ip_mask->ip4dst) ==MULTICAST_ADDR_START ) { + spec->match_fields = + (1 <<MC_CMD_FILTER_OP_V3_IN_MATCH_UNKNOWN_IPV4_MCAST_DST_LBN ); + ins_index =EFCT_MCDI_FILTER_TBL_ROWS -1 ; + goto success; + }else { +netif_err (efct, drv, efct->net_dev, +"Unsupported filter\n" ); +return -EOPNOTSUPP ; + } + +for (index =0 ; index <EFCT_MCDI_FILTER_TBL_ROWS ; index++) { +//TODO hash table implementation + spec_in_table = (struct efct_filter_spec *)table->entry[index].spec; +if (!spec_in_table) { +if (ins_index <0 ) + ins_index = index; + }else if (efct_filter_spec_equal (spec, spec_in_table)) { + ins_index = index; +break ; + } + } + +if (ins_index <0 ) { +netif_err (efct, drv, efct->net_dev, +"No free index found, %d\n" , rc); +return -EBUSY ; + } + +success: + rc = ins_index; +return rc; +} + +int efct_delete_rule (struct efct_nic *efct,u32 id) +{ +struct efct_filter_spec *spec_in_table; +struct efct_mcdi_filter_table *table; +int rc; + +if (!efct) { +pr_err ("Invalid client passed\n" ); +return -ENODEV ; + } + + table = efct->filter_table; +if (!table || !table->entry) { +netif_err (efct, drv, efct->net_dev, +"Invlid filter table\n" ); +return -EINVAL ; + } + +down_write (&table->lock); + +if (table->entry[id].handle ==EFCT_HANDLE_INVALID ) { +netif_err (efct, drv, efct->net_dev, +"Invalid filter is passed, id: %d\n" , id); + rc = -EINVAL ; + goto out; + } + + table->entry[id].ref_cnt--; +if (table->entry[id].ref_cnt) { +netif_dbg (efct, drv, efct->net_dev, +"There are other active clients for this filter, id: %d\n" , id); + rc =0 ; + goto out; + } + + spec_in_table = (struct efct_filter_spec *)table->entry[id].spec; + rc =efct_mcdi_filter_remove (efct, table->entry[id].handle); +if (rc) { +netif_err (efct, drv, efct->net_dev, +"efct_mcdi_filter_remove failed, rc: %d\n" , rc); + goto out; + } +if (spec_in_table->queue_id !=RX_CLS_FLOW_DISC ) + efct->rxq[spec_in_table->queue_id].filter_count--; + +/*Removing exclusive client if filter count is zero*/ +kfree (spec_in_table); + table->entry[id].spec = (unsigned long )NULL ; + table->entry[id].handle =EFCT_HANDLE_INVALID ; +out: +up_write (&table->lock); +return rc; +} +int efct_get_phys_port_id (struct net_device *net_dev,struct netdev_phys_item_id *ppid) {struct efct_nic *efct =efct_netdev_priv (net_dev);
drivers/net/ethernet/amd/efct/efct_ethtool.c new file +1286 -0
1,286 lines not on this page · raw message
drivers/net/ethernet/amd/efct/efct_netdev.c +1 -0
@@ -447,6 +447,7 @@ int efct_register_netdev(struct efct_nic *efct) net_dev->min_mtu =EFCT_MIN_MTU ; net_dev->max_mtu =EFCT_MAX_MTU ; + net_dev->ethtool_ops = &efct_ethtool_ops; efct->netdev_notifier.notifier_call = efct_netdev_event; rc =register_netdevice_notifier (&efct->netdev_notifier);if (rc) {
Signature · 1 line
2.25.1
Re: [PATCH 5/6] net: ethernet: efct: Add ethtool support
drivers/net/ethernet/amd/efct/efct_ethtool.c line 95
Quoted 12 lines
drivers/net/ethernet/amd/efct/efct_ethtool.c new file +12
-0+static void efct_ethtool_get_drvinfo (struct net_device *net_dev, +struct ethtool_drvinfo *info) +{ +struct efct_device *efct_dev; +struct efct_nic *efct; + + efct =efct_netdev_priv (net_dev); + efct_dev =efct_nic_to_device (efct); +strscpy (info->driver,KBUILD_MODNAME ,sizeof (info->driver)); +if (!in_interrupt ()) { +efct_mcdi_print_fwver (efct, info->fw_version,sizeof (info->fw_version)); +efct_mcdi_erom_ver (efct, info->erom_version,sizeof (info->erom_version));
What is the code path where ethtool ops are called in interrupt context?
drivers/net/ethernet/amd/efct/efct_ethtool.c line 101
Quoted 6 lines
drivers/net/ethernet/amd/efct/efct_ethtool.c new file +6
-0+ }else { +strscpy (info->fw_version,"N/A" ,sizeof (info->fw_version)); +strscpy (info->erom_version,"N/A" ,sizeof (info->erom_version)); + } +strscpy (info->bus_info,pci_name (efct_dev->pci_dev),sizeof (info->bus_info)); + info->n_priv_flags =0 ;
Why set it to zero?
drivers/net/ethernet/amd/efct/efct_ethtool.c line 305
Quoted 4 lines
drivers/net/ethernet/amd/efct/efct_ethtool.c new file +4
-0+ data +=EFCT_ETHTOOL_SW_STAT_COUNT ; +for (i =0 ; i <EFCT_MAX_CORE_TX_QUEUES ; i++) { + data[0 ] = efct->txq[i].tx_packets; + data++;
pretty unusual way to do this, Why not *data++ = efct->txq[i].tx_packets ?
Quoted 7 lines
drivers/net/ethernet/amd/efct/efct_ethtool.c new file +7
-0+static int efct_ethtool_get_coalesce (struct net_device *net_dev, +struct ethtool_coalesce *coalesce, +struct kernel_ethtool_coalesce *kernel_coal, +struct netlink_ext_ack *extack) +{ +struct efct_nic *efct =efct_netdev_priv (net_dev); +u32 tx_usecs, rx_usecs;
drivers/net/ethernet/amd/efct/efct_ethtool.c line 372
Quoted 10 lines
drivers/net/ethernet/amd/efct/efct_ethtool.c new file +10
-0+ + tx_usecs =0 ; + rx_usecs =0 ; +efct_get_tx_moderation (efct, &tx_usecs); +efct_get_rx_moderation (efct, &rx_usecs); + coalesce->tx_coalesce_usecs = tx_usecs; + coalesce->tx_coalesce_usecs_irq =0 ; + coalesce->rx_coalesce_usecs = rx_usecs; + coalesce->rx_coalesce_usecs_irq =0 ; + coalesce->use_adaptive_rx_coalesce = efct->irq_rx_adaptive;
As a general rule of thumb, in any linux get callbacks, you only need to set values if they are not 0. So you can skip the irqs.
Quoted 10 lines
drivers/net/ethernet/amd/efct/efct_ethtool.c new file +10
-0+static int efct_ethtool_set_coalesce (struct net_device *net_dev, +struct ethtool_coalesce *coalesce, +struct kernel_ethtool_coalesce *kernel_coal, +struct netlink_ext_ack *extack) +{ +struct efct_nic *efct =efct_netdev_priv (net_dev); +struct efct_ev_queue *evq; +u32 tx_usecs, rx_usecs; +u32 timer_max_us; +bool tx = false;
drivers/net/ethernet/amd/efct/efct_ethtool.c line 396
Quoted 10 lines
drivers/net/ethernet/amd/efct/efct_ethtool.c new file +10
-0+bool rx = false; +int i; + + tx_usecs =0 ; + rx_usecs =0 ; + timer_max_us = efct->timer_max_ns /1000 ; + evq = efct->evq; + +if (coalesce->rx_coalesce_usecs_irq || coalesce->tx_coalesce_usecs_irq) { +netif_err (efct, drv, efct->net_dev,"Only rx/tx_coalesce_usecs are supported\n" );
This is not an error. This is just userspace not knowing what you hardware can do. netif_dbg(), or nothing at all.
Review
Quoted 1 line
(quoted diff) +1
-0+ return -EINVAL;
EOPNOTSUP would be more accurate. Your hardware cannot do it, so it is not supported.
drivers/net/ethernet/amd/efct/efct_ethtool.c line 463
Quoted 13 lines
drivers/net/ethernet/amd/efct/efct_ethtool.c new file +13
-0+static int efct_ethtool_set_ringparam (struct net_device *net_dev, +struct ethtool_ringparam *ring, +struct kernel_ethtool_ringparam *kring, +struct netlink_ext_ack *ext_ack) +{ +struct efct_nic *efct =efct_netdev_priv (net_dev); +u32 entries_per_buff, min_rx_num_entries; +bool if_up = false; +int rc; + +if (ring->tx_pending != efct->txq[0 ].num_entries) { +netif_err (efct, drv, efct->net_dev, +"Tx ring size changes not supported\n" );
netif_dbg()
Quoted 4 lines
drivers/net/ethernet/amd/efct/efct_ethtool.c new file +4
-0+return -EOPNOTSUPP ; + } + +if (ring->rx_pending == efct->rxq[0 ].num_entries)
drivers/net/ethernet/amd/efct/efct_ethtool.c line 477
Quoted 10 lines
drivers/net/ethernet/amd/efct/efct_ethtool.c new file +10
-0+/* Nothing to do */ +return 0 ; + + min_rx_num_entries =RX_MIN_DRIVER_BUFFS *DIV_ROUND_UP (efct->rxq[0 ].buffer_size, + efct->rxq[0 ].pkt_stride); + entries_per_buff =DIV_ROUND_UP (efct->rxq[0 ].buffer_size, efct->rxq[0 ].pkt_stride); +if (ring->rx_pending % entries_per_buff || ring->rx_pending < min_rx_num_entries) { +netif_err (efct, drv, efct->net_dev, +"Unsupported RX ring size. Should be multiple of %u and more than %u" , + entries_per_buff, min_rx_num_entries);
netif_dbg()
Quoted 7 lines
drivers/net/ethernet/amd/efct/efct_ethtool.c new file +7
-0+return -EINVAL ; + } + +ASSERT_RTNL (); + +if (netif_running (net_dev)) { +dev_close (net_dev);
drivers/net/ethernet/amd/efct/efct_ethtool.c line 494
Quoted 10 lines
drivers/net/ethernet/amd/efct/efct_ethtool.c new file +10
-0+ if_up = true; + } + +mutex_lock (&efct->state_lock); + rc =efct_realloc_rx_evqs (efct, ring->rx_pending); +mutex_unlock (&efct->state_lock); + +if (rc) { +netif_err (efct, drv, efct->net_dev, +"Failed reallocate rx evqs. Device disabled\n" );
This not how it should work, precisely because of this problem of what to do when there is no memory available. What you should do is first allocate the memory needed for the new rings, and if that is successful, free the old rings and swap to the new memory. If you cannot allocate the new memory, no harm has been done, you still have the rings, return -ENOMEM and life goes on.
drivers/net/ethernet/amd/efct/efct_ethtool.c line 538
Quoted 11 lines
drivers/net/ethernet/amd/efct/efct_ethtool.c new file +11
-0+int efct_mcdi_phy_set_ksettings (struct efct_nic *efct, +const struct ethtool_link_ksettings *settings, +unsigned long *advertising) +{ +const struct ethtool_link_settings *base = &settings->base; +struct efct_mcdi_phy_data *phy_cfg = efct->phy_data; +u32 caps; +int rc; + +memcpy (advertising, settings->link_modes.advertising, +sizeof (__ETHTOOL_DECLARE_LINK_MODE_MASK ()));
linkmode_copy()
drivers/net/ethernet/amd/efct/efct_ethtool.c line 546
Quoted 8 lines
drivers/net/ethernet/amd/efct/efct_ethtool.c new file +8
-0+ +/* Remove flow control settings that the MAC supports +* but that the PHY can't advertise. +*/ +if (~phy_cfg->supported_cap & (1 <<MC_CMD_PHY_CAP_PAUSE_LBN )) +__clear_bit (ETHTOOL_LINK_MODE_Pause_BIT, advertising); +if (~phy_cfg->supported_cap & (1 <<MC_CMD_PHY_CAP_ASYM_LBN )) +__clear_bit (ETHTOOL_LINK_MODE_Asym_Pause_BIT, advertising);
linkmode_clear_bit()
drivers/net/ethernet/amd/efct/efct_ethtool.c line 1270
Quoted 4 lines
drivers/net/ethernet/amd/efct/efct_ethtool.c new file +4
-0+ .get_coalesce = efct_ethtool_get_coalesce, + .set_coalesce = efct_ethtool_set_coalesce, + .get_ringparam = efct_ethtool_get_ringparam, + .set_ringparam = efct_ethtool_set_ringparam,
tab vs spaces issues. checkpatch.pl should of told you about that. You are using checkpatch right?
Andrew
PATCH 6/6 net: ethernet: efct: Add maintainer, kconfig, makefile
In reply to Harsh JainInclude driver in kernel build system.
--- MAINTAINERS | 7 +++++ drivers/net/ethernet/amd/Kconfig | 2 ++ drivers/net/ethernet/amd/Makefile | 2 ++ drivers/net/ethernet/amd/efct/Kconfig | 40 ++++++++++++++++++++++++++ drivers/net/ethernet/amd/efct/Makefile | 13 +++++++++ 5 files changed, 64 insertions(+) create mode 100644 drivers/net/ethernet/amd/efct/Kconfig create mode 100644 drivers/net/ethernet/amd/efct/Makefile
MAINTAINERS +7 -0
@@ -7611,6 +7611,13 @@ S: Maintained T: git git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git F: sound/usb/misc/ua101.c +EFCT NETWORK DRIVER +M: Harsh Jain<[email protected]> +M: Nikhil Agarwal <[email protected]> +L: [email protected] +S: Supported +F: drivers/net/ethernet/amd/efct/ + EFI TEST DRIVER M: Ivan Hu <[email protected]> M: Ard Biesheuvel <[email protected]>
drivers/net/ethernet/amd/Kconfig +2 -0
@@ -186,4 +186,6 @@ config AMD_XGBE_HAVE_ECC bool default n +source "drivers/net/ethernet/amd/efct/Kconfig" + endif # NET_VENDOR_AMD
drivers/net/ethernet/amd/Makefile +2 -0
@@ -17,3 +17,5 @@ obj-$(CONFIG_PCNET32) += pcnet32.o obj-$(CONFIG_SUN3LANCE) += sun3lance.o obj-$(CONFIG_SUNLANCE) += sunlance.o obj-$(CONFIG_AMD_XGBE) += xgbe/ +obj-$(CONFIG_EFCT) += efct/ +
drivers/net/ethernet/amd/efct/Kconfig new file +40 -0
@@ -0,0 +1,40 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +################################################################################ +# +# Driver for AMD/Xilinx network controllers and boards +# Copyright (C) 2021, Xilinx, Inc. +# Copyright (C) 2022-2023, Advanced Micro Devices, Inc. +################################################################################# +# +# + + +config EFCT + tristate "AMD X3 support" + depends on PCI && (X86 || ARCH_DMA_ADDR_T_64BIT) + default m + select NET_DEVLINK + select MDIO + select CRC32 + help + Supports Ethernet cards based on the Xilinx X3 networking IP in AMD/Xilinx FPGAs + To compile this driver as a module, choose M here. The module + will be called efct. + +config EFCT_MCDI_LOGGING + bool "MCDI logging support" + depends on EFCT + default n + help + This enables support for tracing of MCDI (Management-Controller-to- + Driver-Interface) commands and responses, allowing debugging of + driver/firmware interaction. + +config EFCT_PTP + bool "PTP support" + depends on EFCT + default y + select PTP_1588_CLOCK + help + This enables support for the Precision Time Protocol.
drivers/net/ethernet/amd/efct/Makefile new file +13 -0
@@ -0,0 +1,13 @@ +################################################################################ +# Driver for AMD/Xilinx network controllers and boards +# Copyright (C) 2021, Xilinx, Inc. +# Copyright (C) 2022-2023, Advanced Micro Devices, Inc. +################################################################################ + + +efct-y := mcdi.o mcdi_port_common.o mcdi_functions.o efct_netdev.o efct_common.o \ + efct_nic.o efct_pci.o efct_evq.o efct_tx.o efct_rx.o efct_ethtool.o \ + efct_reflash.o efct_devlink.o + +efct-$(CONFIG_EFCT_PTP) += efct_ptp.o +obj-$(CONFIG_EFCT) += efct.o
Signature · 1 line
2.25.1
kernel test robot
build botRe: [PATCH 6/6] net: ethernet: efct: Add maintainer, kconfig, makefile
I love your patch! Yet something to improve:
Hi Harsh,
I love your patch! Yet something to improve:
[auto build test ERROR on net-next/master]
[also build test ERROR on net/master horms-ipvs/master linus/master v6.2-rc7 next-20230210] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Harsh-Jain/net-ethernet-efct-New-X3-net-driver/20230210-210711 patch link: https://lore.kernel.org/r/20230210130321.2898-7-h.jain%40amd.com patch subject: [PATCH 6/6] net: ethernet: efct: Add maintainer, kconfig, makefile config: mips-db1xxx_defconfig (https://download.01.org/0day-ci/archive/20230211/[email protected]/config) compiler: mipsel-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/93ed306161ac0259bd72b14922a7f6af60b3748c
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Harsh-Jain/net-ethernet-efct-New-X3-net-driver/20230210-210711
git checkout 93ed306161ac0259bd72b14922a7f6af60b3748c
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=mips olddefconfig COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=mips SHELL=/bin/bash drivers/net/ethernet/amd/efct/
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>
| Link: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All error/warnings (new ones prefixed by >>):
drivers/net/ethernet/amd/efct/mcdi_functions.c: In function 'efct_mcdi_filter_table_probe':
>> drivers/net/ethernet/amd/efct/mcdi_functions.c:283:24: error: implicit declaration of function 'vzalloc'; did you mean 'kvzalloc'? [-Werror=implicit-function-declaration]
283 | table->entry = vzalloc(EFCT_MCDI_FILTER_TBL_ROWS *
| ^~~~~~~
| kvzalloc
>> drivers/net/ethernet/amd/efct/mcdi_functions.c:283:22: warning: assignment to 'struct <anonymous> *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
283 | table->entry = vzalloc(EFCT_MCDI_FILTER_TBL_ROWS *
| ^
drivers/net/ethernet/amd/efct/mcdi_functions.c: In function 'efct_mcdi_filter_table_remove':
>> drivers/net/ethernet/amd/efct/mcdi_functions.c:309:9: error: implicit declaration of function 'vfree'; did you mean 'kfree'? [-Werror=implicit-function-declaration]
309 | vfree(table->entry);
| ^~~~~
| kfreecc1: some warnings being treated as errors
vim +283 drivers/net/ethernet/amd/efct/mcdi_functions.c
83f06a5b784384c Harsh Jain 2023-02-10 267
83f06a5b784384c Harsh Jain 2023-02-10 268 int efct_mcdi_filter_table_probe(struct efct_nic *efct)
83f06a5b784384c Harsh Jain 2023-02-10 269 {
83f06a5b784384c Harsh Jain 2023-02-10 270 struct efct_mcdi_filter_table *table;
83f06a5b784384c Harsh Jain 2023-02-10 271 int rc = 0, i;
83f06a5b784384c Harsh Jain 2023-02-10 272
83f06a5b784384c Harsh Jain 2023-02-10 273 if (efct->filter_table) /* already probed */
83f06a5b784384c Harsh Jain 2023-02-10 274 return rc;
83f06a5b784384c Harsh Jain 2023-02-10 275
83f06a5b784384c Harsh Jain 2023-02-10 276 table = kzalloc(sizeof(*table), GFP_KERNEL);
83f06a5b784384c Harsh Jain 2023-02-10 277 if (!table)
83f06a5b784384c Harsh Jain 2023-02-10 278 return -ENOMEM;
83f06a5b784384c Harsh Jain 2023-02-10 279
83f06a5b784384c Harsh Jain 2023-02-10 280 efct->filter_table = table;
83f06a5b784384c Harsh Jain 2023-02-10 281
83f06a5b784384c Harsh Jain 2023-02-10 282 init_rwsem(&table->lock);
83f06a5b784384c Harsh Jain 2023-02-10 @283 table->entry = vzalloc(EFCT_MCDI_FILTER_TBL_ROWS *
83f06a5b784384c Harsh Jain 2023-02-10 284 sizeof(*table->entry));
83f06a5b784384c Harsh Jain 2023-02-10 285 if (!table->entry) {
83f06a5b784384c Harsh Jain 2023-02-10 286 rc = -ENOMEM;
83f06a5b784384c Harsh Jain 2023-02-10 287 return rc;
83f06a5b784384c Harsh Jain 2023-02-10 288 }
83f06a5b784384c Harsh Jain 2023-02-10 289
83f06a5b784384c Harsh Jain 2023-02-10 290 for (i = 0; i < EFCT_MCDI_FILTER_TBL_ROWS; i++) {
83f06a5b784384c Harsh Jain 2023-02-10 291 table->entry[i].handle = EFCT_HANDLE_INVALID;
83f06a5b784384c Harsh Jain 2023-02-10 292 table->entry[i].ref_cnt = 0;
83f06a5b784384c Harsh Jain 2023-02-10 293 }
83f06a5b784384c Harsh Jain 2023-02-10 294
83f06a5b784384c Harsh Jain 2023-02-10 295 return rc;
83f06a5b784384c Harsh Jain 2023-02-10 296 }
83f06a5b784384c Harsh Jain 2023-02-10 297
83f06a5b784384c Harsh Jain 2023-02-10 298 void efct_mcdi_filter_table_remove(struct efct_nic *efct)
83f06a5b784384c Harsh Jain 2023-02-10 299 {
83f06a5b784384c Harsh Jain 2023-02-10 300 struct efct_mcdi_filter_table *table = efct->filter_table;
83f06a5b784384c Harsh Jain 2023-02-10 301 int i;
83f06a5b784384c Harsh Jain 2023-02-10 302
83f06a5b784384c Harsh Jain 2023-02-10 303 if (!table)
83f06a5b784384c Harsh Jain 2023-02-10 304 return;
83f06a5b784384c Harsh Jain 2023-02-10 305 for (i = 0; i < EFCT_MCDI_FILTER_TBL_ROWS; i++) {
83f06a5b784384c Harsh Jain 2023-02-10 306 if (table->entry[i].spec)
83f06a5b784384c Harsh Jain 2023-02-10 307 kfree((struct efct_filter_spec *)table->entry[i].spec);
83f06a5b784384c Harsh Jain 2023-02-10 308 }
83f06a5b784384c Harsh Jain 2023-02-10 @309 vfree(table->entry);
83f06a5b784384c Harsh Jain 2023-02-10 310 table->entry = NULL;
83f06a5b784384c Harsh Jain 2023-02-10 311 efct->filter_table = NULL;
83f06a5b784384c Harsh Jain 2023-02-10 312 kfree(table);
83f06a5b784384c Harsh Jain 2023-02-10 313 }83f06a5b784384c Harsh Jain 2023-02-10 314
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests
kernel test robot
build botRe: [PATCH 6/6] net: ethernet: efct: Add maintainer, kconfig, makefile
In reply to Harsh JainI love your patch! Perhaps something to improve:
Hi Harsh,
I love your patch! Perhaps something to improve:
[auto build test WARNING on net-next/master]
[also build test WARNING on net/master horms-ipvs/master linus/master v6.2-rc7 next-20230210] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Harsh-Jain/net-ethernet-efct-New-X3-net-driver/20230210-210711 patch link: https://lore.kernel.org/r/20230210130321.2898-7-h.jain%40amd.com patch subject: [PATCH 6/6] net: ethernet: efct: Add maintainer, kconfig, makefile config: i386-defconfig (https://download.01.org/0day-ci/archive/20230211/[email protected]/config) compiler: gcc-11 (Debian 11.3.0-8) 11.3.0
reproduce (this is a W=1 build):
# https://github.com/intel-lab-lkp/linux/commit/93ed306161ac0259bd72b14922a7f6af60b3748c
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Harsh-Jain/net-ethernet-efct-New-X3-net-driver/20230210-210711 git checkout 93ed306161ac0259bd72b14922a7f6af60b3748c
# save the config file
mkdir build_dir && cp config build_dir/.config
make W=1 O=build_dir ARCH=i386 olddefconfig
make W=1 O=build_dir ARCH=i386 SHELL=/bin/bash drivers/net/ io_uring//
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>
| Link: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
In file included from drivers/net/ethernet/amd/efct/efct_nic.c:15:
drivers/net/ethernet/amd/efct/efct_io.h: In function '_efct_writeq':
drivers/net/ethernet/amd/efct/efct_io.h:57:9: error: implicit declaration of function '__raw_writeq'; did you mean '_efct_writeq'? [-Werror=implicit-function-declaration]
57 | __raw_writeq((__force u64)value, reg);
| ^~~~~~~~~~~~
| _efct_writeq
drivers/net/ethernet/amd/efct/efct_io.h: In function '_efct_readq':
drivers/net/ethernet/amd/efct/efct_io.h:62:32: error: implicit declaration of function '__raw_readq' [-Werror=implicit-function-declaration]
62 | return (__force __le64)__raw_readq(reg);
| ^~~~~~~~~~~
In file included from drivers/net/ethernet/amd/efct/efct_driver.h:25,
from drivers/net/ethernet/amd/efct/efct_common.h:13,
from drivers/net/ethernet/amd/efct/efct_nic.c:10:
drivers/net/ethernet/amd/efct/efct_nic.c: In function 'efct_time_sync_event':
>> drivers/net/ethernet/amd/efct/efct_bitfield.h:112:27: warning: left shift count >= width of type [-Wshift-count-overflow]
112 | (native_element) << ((min) - (low)))
| ^~
drivers/net/ethernet/amd/efct/efct_bitfield.h:124:9: note: in expansion of macro 'EFCT_EXTRACT_NATIVE'
124 | EFCT_EXTRACT_NATIVE(le32_to_cpu(element), min, max, low, high)
| ^~~~~~~~~~~~~~~~~~~
drivers/net/ethernet/amd/efct/efct_bitfield.h:144:11: note: in expansion of macro 'EFCT_EXTRACT32'
144 | EFCT_EXTRACT32((qword).u32[1], 32, 63, low, high)) & \
| ^~~~~~~~~~~~~~
drivers/net/ethernet/amd/efct/efct_bitfield.h:164:9: note: in expansion of macro 'EFCT_EXTRACT_QWORD32'
164 | EFCT_EXTRACT_QWORD32(qword, EFCT_LOW_BIT(field), \
| ^~~~~~~~~~~~~~~~~~~~
drivers/net/ethernet/amd/efct/efct_bitfield.h:212:41: note: in expansion of macro 'EFCT_QWORD_FIELD32'
212 | #define EFCT_QWORD_FIELD EFCT_QWORD_FIELD32
| ^~~~~~~~~~~~~~~~~~
drivers/net/ethernet/amd/efct/efct_nic.c:746:38: note: in expansion of macro 'EFCT_QWORD_FIELD'
746 | evq->sync_timestamp_major = EFCT_QWORD_FIELD(*p_event, ESF_HZ_EV_TSYNC_TIME_HIGH_48);
| ^~~~~~~~~~~~~~~~
drivers/net/ethernet/amd/efct/efct_bitfield.h:69:22: warning: left shift count >= width of type [-Wshift-count-overflow]
69 | (((((u32)1) << (width))) - 1))
| ^~
drivers/net/ethernet/amd/efct/efct_bitfield.h:145:10: note: in expansion of macro 'EFCT_MASK32'
145 | EFCT_MASK32((high) + 1 - (low)))
| ^~~~~~~~~~~
drivers/net/ethernet/amd/efct/efct_bitfield.h:164:9: note: in expansion of macro 'EFCT_EXTRACT_QWORD32'
164 | EFCT_EXTRACT_QWORD32(qword, EFCT_LOW_BIT(field), \
| ^~~~~~~~~~~~~~~~~~~~
drivers/net/ethernet/amd/efct/efct_bitfield.h:212:41: note: in expansion of macro 'EFCT_QWORD_FIELD32'
212 | #define EFCT_QWORD_FIELD EFCT_QWORD_FIELD32
| ^~~~~~~~~~~~~~~~~~
drivers/net/ethernet/amd/efct/efct_nic.c:746:38: note: in expansion of macro 'EFCT_QWORD_FIELD'
746 | evq->sync_timestamp_major = EFCT_QWORD_FIELD(*p_event, ESF_HZ_EV_TSYNC_TIME_HIGH_48);
| ^~~~~~~~~~~~~~~~ cc1: some warnings being treated as errors
--
In file included from drivers/net/ethernet/amd/efct/efct_tx.c:11:
drivers/net/ethernet/amd/efct/efct_io.h: In function '_efct_writeq':
drivers/net/ethernet/amd/efct/efct_io.h:57:9: error: implicit declaration of function '__raw_writeq'; did you mean '_efct_writeq'? [-Werror=implicit-function-declaration]
57 | __raw_writeq((__force u64)value, reg);
| ^~~~~~~~~~~~
| _efct_writeq
drivers/net/ethernet/amd/efct/efct_io.h: In function '_efct_readq':
drivers/net/ethernet/amd/efct/efct_io.h:62:32: error: implicit declaration of function '__raw_readq' [-Werror=implicit-function-declaration]
62 | return (__force __le64)__raw_readq(reg);
| ^~~~~~~~~~~
drivers/net/ethernet/amd/efct/efct_tx.c: In function 'txq_piobuf_w64':
drivers/net/ethernet/amd/efct/efct_tx.c:89:9: error: implicit declaration of function 'writeq'; did you mean 'writel'? [-Werror=implicit-function-declaration]
89 | writeq(val, dest64);
| ^~~~~~
| writel
In file included from drivers/net/ethernet/amd/efct/efct_driver.h:25,
from drivers/net/ethernet/amd/efct/efct_tx.h:11,
from drivers/net/ethernet/amd/efct/efct_tx.c:9:
drivers/net/ethernet/amd/efct/efct_tx.c: In function 'efct_ev_tx':
>> drivers/net/ethernet/amd/efct/efct_bitfield.h:112:27: warning: left shift count >= width of type [-Wshift-count-overflow]
112 | (native_element) << ((min) - (low)))
| ^~
drivers/net/ethernet/amd/efct/efct_bitfield.h:124:9: note: in expansion of macro 'EFCT_EXTRACT_NATIVE'
124 | EFCT_EXTRACT_NATIVE(le32_to_cpu(element), min, max, low, high)
| ^~~~~~~~~~~~~~~~~~~
drivers/net/ethernet/amd/efct/efct_bitfield.h:144:11: note: in expansion of macro 'EFCT_EXTRACT32'
144 | EFCT_EXTRACT32((qword).u32[1], 32, 63, low, high)) & \
| ^~~~~~~~~~~~~~
drivers/net/ethernet/amd/efct/efct_bitfield.h:164:9: note: in expansion of macro 'EFCT_EXTRACT_QWORD32'
164 | EFCT_EXTRACT_QWORD32(qword, EFCT_LOW_BIT(field), \
| ^~~~~~~~~~~~~~~~~~~~
drivers/net/ethernet/amd/efct/efct_bitfield.h:212:41: note: in expansion of macro 'EFCT_QWORD_FIELD32'
212 | #define EFCT_QWORD_FIELD EFCT_QWORD_FIELD32
| ^~~~~~~~~~~~~~~~~~
drivers/net/ethernet/amd/efct/efct_tx.c:326:22: note: in expansion of macro 'EFCT_QWORD_FIELD'
326 | partial_ts = EFCT_QWORD_FIELD(*p_event, ESF_HZ_EV_TXCMPL_PARTIAL_TSTAMP);
| ^~~~~~~~~~~~~~~~
drivers/net/ethernet/amd/efct/efct_bitfield.h:69:22: warning: left shift count >= width of type [-Wshift-count-overflow]
69 | (((((u32)1) << (width))) - 1))
| ^~
drivers/net/ethernet/amd/efct/efct_bitfield.h:145:10: note: in expansion of macro 'EFCT_MASK32'
145 | EFCT_MASK32((high) + 1 - (low)))
| ^~~~~~~~~~~
drivers/net/ethernet/amd/efct/efct_bitfield.h:164:9: note: in expansion of macro 'EFCT_EXTRACT_QWORD32'
164 | EFCT_EXTRACT_QWORD32(qword, EFCT_LOW_BIT(field), \
| ^~~~~~~~~~~~~~~~~~~~
drivers/net/ethernet/amd/efct/efct_bitfield.h:212:41: note: in expansion of macro 'EFCT_QWORD_FIELD32'
212 | #define EFCT_QWORD_FIELD EFCT_QWORD_FIELD32
| ^~~~~~~~~~~~~~~~~~
drivers/net/ethernet/amd/efct/efct_tx.c:326:22: note: in expansion of macro 'EFCT_QWORD_FIELD'
326 | partial_ts = EFCT_QWORD_FIELD(*p_event, ESF_HZ_EV_TXCMPL_PARTIAL_TSTAMP);
| ^~~~~~~~~~~~~~~~ cc1: some warnings being treated as errors
--
In file included from drivers/net/ethernet/amd/efct/efct_rx.c:15:
drivers/net/ethernet/amd/efct/efct_io.h: In function '_efct_writeq':
drivers/net/ethernet/amd/efct/efct_io.h:57:9: error: implicit declaration of function '__raw_writeq'; did you mean '_efct_writeq'? [-Werror=implicit-function-declaration]
57 | __raw_writeq((__force u64)value, reg);
| ^~~~~~~~~~~~
| _efct_writeq
drivers/net/ethernet/amd/efct/efct_io.h: In function '_efct_readq':
drivers/net/ethernet/amd/efct/efct_io.h:62:32: error: implicit declaration of function '__raw_readq' [-Werror=implicit-function-declaration]
62 | return (__force __le64)__raw_readq(reg);
| ^~~~~~~~~~~
In file included from drivers/net/ethernet/amd/efct/efct_driver.h:25,
from drivers/net/ethernet/amd/efct/efct_rx.h:11,
from drivers/net/ethernet/amd/efct/efct_rx.c:12:
drivers/net/ethernet/amd/efct/efct_rx.c: In function 'efct_include_ts_in_rxskb':
>> drivers/net/ethernet/amd/efct/efct_bitfield.h:112:27: warning: left shift count >= width of type [-Wshift-count-overflow]
112 | (native_element) << ((min) - (low)))
| ^~
drivers/net/ethernet/amd/efct/efct_bitfield.h:124:9: note: in expansion of macro 'EFCT_EXTRACT_NATIVE'
124 | EFCT_EXTRACT_NATIVE(le32_to_cpu(element), min, max, low, high)
| ^~~~~~~~~~~~~~~~~~~
drivers/net/ethernet/amd/efct/efct_bitfield.h:139:11: note: in expansion of macro 'EFCT_EXTRACT32'
139 | EFCT_EXTRACT32((oword).u32[3], 96, 127, low, high)) & \
| ^~~~~~~~~~~~~~
drivers/net/ethernet/amd/efct/efct_bitfield.h:160:9: note: in expansion of macro 'EFCT_EXTRACT_OWORD32'
160 | EFCT_EXTRACT_OWORD32(oword, EFCT_LOW_BIT(field), \
| ^~~~~~~~~~~~~~~~~~~~
drivers/net/ethernet/amd/efct/efct_bitfield.h:211:41: note: in expansion of macro 'EFCT_OWORD_FIELD32'
211 | #define EFCT_OWORD_FIELD EFCT_OWORD_FIELD32
| ^~~~~~~~~~~~~~~~~~
drivers/net/ethernet/amd/efct/efct_rx.c:386:24: note: in expansion of macro 'EFCT_OWORD_FIELD'
386 | pkt_ts_major = EFCT_OWORD_FIELD(*((union efct_oword *)p_meta), ESF_HZ_RX_PREFIX_TIMESTAMP);
| ^~~~~~~~~~~~~~~~
drivers/net/ethernet/amd/efct/efct_bitfield.h:69:22: warning: left shift count >= width of type [-Wshift-count-overflow]
69 | (((((u32)1) << (width))) - 1))
| ^~
drivers/net/ethernet/amd/efct/efct_bitfield.h:140:10: note: in expansion of macro 'EFCT_MASK32'
140 | EFCT_MASK32((high) + 1 - (low)))
| ^~~~~~~~~~~
drivers/net/ethernet/amd/efct/efct_bitfield.h:160:9: note: in expansion of macro 'EFCT_EXTRACT_OWORD32'
160 | EFCT_EXTRACT_OWORD32(oword, EFCT_LOW_BIT(field), \
| ^~~~~~~~~~~~~~~~~~~~
drivers/net/ethernet/amd/efct/efct_bitfield.h:211:41: note: in expansion of macro 'EFCT_OWORD_FIELD32'
211 | #define EFCT_OWORD_FIELD EFCT_OWORD_FIELD32
| ^~~~~~~~~~~~~~~~~~
drivers/net/ethernet/amd/efct/efct_rx.c:386:24: note: in expansion of macro 'EFCT_OWORD_FIELD'
386 | pkt_ts_major = EFCT_OWORD_FIELD(*((union efct_oword *)p_meta), ESF_HZ_RX_PREFIX_TIMESTAMP);
| ^~~~~~~~~~~~~~~~cc1: some warnings being treated as errors
vim +112 drivers/net/ethernet/amd/efct/efct_bitfield.h
83f06a5b784384 Harsh Jain 2023-02-10 90 83f06a5b784384 Harsh Jain 2023-02-10 91 /* Format string and value expanders for printk */ 83f06a5b784384 Harsh Jain 2023-02-10 92 #define EFCT_DWORD_FMT "%08x" 83f06a5b784384 Harsh Jain 2023-02-10 93 #define EFCT_OWORD_FMT "%08x:%08x:%08x:%08x" 83f06a5b784384 Harsh Jain 2023-02-10 94 #define EFCT_DWORD_VAL(dword) \ 83f06a5b784384 Harsh Jain 2023-02-10 95 ((u32)le32_to_cpu((dword).word32)) 83f06a5b784384 Harsh Jain 2023-02-10 96 83f06a5b784384 Harsh Jain 2023-02-10 97 /* Extract bit field portion [low,high) from the native-endian element 83f06a5b784384 Harsh Jain 2023-02-10 98 * which contains bits [min,max). 83f06a5b784384 Harsh Jain 2023-02-10 99 * For example, suppose "element" represents the high 32 bits of a 83f06a5b784384 Harsh Jain 2023-02-10 100 * 64-bit value, and we wish to extract the bits belonging to the bit 83f06a5b784384 Harsh Jain 2023-02-10 101 * field occupying bits 28-45 of this 64-bit value. 83f06a5b784384 Harsh Jain 2023-02-10 102 * Then EFCT_EXTRACT ( element, 32, 63, 28, 45 ) would give 83f06a5b784384 Harsh Jain 2023-02-10 103 * 83f06a5b784384 Harsh Jain 2023-02-10 104 * ( element ) << 4 83f06a5b784384 Harsh Jain 2023-02-10 105 * The result will contain the relevant bits filled in the range 83f06a5b784384 Harsh Jain 2023-02-10 106 * [0,high-low), with garbage in bits [high-low+1,...). 83f06a5b784384 Harsh Jain 2023-02-10 107 */ 83f06a5b784384 Harsh Jain 2023-02-10 108 #define EFCT_EXTRACT_NATIVE(native_element, min, max, low, high) \ 83f06a5b784384 Harsh Jain 2023-02-10 109 ((low) > (max) || (high) < (min) ? 0 : \ 83f06a5b784384 Harsh Jain 2023-02-10 110 (low) > (min) ? \ 83f06a5b784384 Harsh Jain 2023-02-10 111 (native_element) >> ((low) - (min)) : \
83f06a5b784384 Harsh Jain 2023-02-10 @112 (native_element) << ((min) - (low)))83f06a5b784384 Harsh Jain 2023-02-10 113
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests
kernel test robot
build botRe: [PATCH 6/6] net: ethernet: efct: Add maintainer, kconfig, makefile
In reply to Harsh JainI love your patch! Yet something to improve:
Hi Harsh,
I love your patch! Yet something to improve:
[auto build test ERROR on net-next/master]
[also build test ERROR on net/master horms-ipvs/master linus/master v6.2-rc7 next-20230210] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Harsh-Jain/net-ethernet-efct-New-X3-net-driver/20230210-210711 patch link: https://lore.kernel.org/r/20230210130321.2898-7-h.jain%40amd.com patch subject: [PATCH 6/6] net: ethernet: efct: Add maintainer, kconfig, makefile config: i386-defconfig (https://download.01.org/0day-ci/archive/20230211/[email protected]/config) compiler: gcc-11 (Debian 11.3.0-8) 11.3.0
reproduce (this is a W=1 build):
# https://github.com/intel-lab-lkp/linux/commit/93ed306161ac0259bd72b14922a7f6af60b3748c
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Harsh-Jain/net-ethernet-efct-New-X3-net-driver/20230210-210711 git checkout 93ed306161ac0259bd72b14922a7f6af60b3748c
# save the config file
mkdir build_dir && cp config build_dir/.config
make W=1 O=build_dir ARCH=i386 olddefconfig
make W=1 O=build_dir ARCH=i386 SHELL=/bin/bash drivers/net/
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>
| Link: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
In file included from drivers/net/ethernet/amd/efct/mcdi.c:12:
drivers/net/ethernet/amd/efct/efct_io.h: In function '_efct_writeq':
>> drivers/net/ethernet/amd/efct/efct_io.h:57:9: error: implicit declaration of function '__raw_writeq'; did you mean '_efct_writeq'? [-Werror=implicit-function-declaration]
57 | __raw_writeq((__force u64)value, reg);
| ^~~~~~~~~~~~
| _efct_writeq
drivers/net/ethernet/amd/efct/efct_io.h: In function '_efct_readq':
>> drivers/net/ethernet/amd/efct/efct_io.h:62:32: error: implicit declaration of function '__raw_readq' [-Werror=implicit-function-declaration]
62 | return (__force __le64)__raw_readq(reg);
| ^~~~~~~~~~~ cc1: some warnings being treated as errors
--
In file included from drivers/net/ethernet/amd/efct/efct_nic.c:15:
drivers/net/ethernet/amd/efct/efct_io.h: In function '_efct_writeq':
>> drivers/net/ethernet/amd/efct/efct_io.h:57:9: error: implicit declaration of function '__raw_writeq'; did you mean '_efct_writeq'? [-Werror=implicit-function-declaration]
57 | __raw_writeq((__force u64)value, reg);
| ^~~~~~~~~~~~
| _efct_writeq
drivers/net/ethernet/amd/efct/efct_io.h: In function '_efct_readq':
>> drivers/net/ethernet/amd/efct/efct_io.h:62:32: error: implicit declaration of function '__raw_readq' [-Werror=implicit-function-declaration]
62 | return (__force __le64)__raw_readq(reg);
| ^~~~~~~~~~~
In file included from drivers/net/ethernet/amd/efct/efct_driver.h:25,
from drivers/net/ethernet/amd/efct/efct_common.h:13,
from drivers/net/ethernet/amd/efct/efct_nic.c:10:
drivers/net/ethernet/amd/efct/efct_nic.c: In function 'efct_time_sync_event':
drivers/net/ethernet/amd/efct/efct_bitfield.h:112:27: warning: left shift count >= width of type [-Wshift-count-overflow]
112 | (native_element) << ((min) - (low)))
| ^~
drivers/net/ethernet/amd/efct/efct_bitfield.h:124:9: note: in expansion of macro 'EFCT_EXTRACT_NATIVE'
124 | EFCT_EXTRACT_NATIVE(le32_to_cpu(element), min, max, low, high)
| ^~~~~~~~~~~~~~~~~~~
drivers/net/ethernet/amd/efct/efct_bitfield.h:144:11: note: in expansion of macro 'EFCT_EXTRACT32'
144 | EFCT_EXTRACT32((qword).u32[1], 32, 63, low, high)) & \
| ^~~~~~~~~~~~~~
drivers/net/ethernet/amd/efct/efct_bitfield.h:164:9: note: in expansion of macro 'EFCT_EXTRACT_QWORD32'
164 | EFCT_EXTRACT_QWORD32(qword, EFCT_LOW_BIT(field), \
| ^~~~~~~~~~~~~~~~~~~~
drivers/net/ethernet/amd/efct/efct_bitfield.h:212:41: note: in expansion of macro 'EFCT_QWORD_FIELD32'
212 | #define EFCT_QWORD_FIELD EFCT_QWORD_FIELD32
| ^~~~~~~~~~~~~~~~~~
drivers/net/ethernet/amd/efct/efct_nic.c:746:38: note: in expansion of macro 'EFCT_QWORD_FIELD'
746 | evq->sync_timestamp_major = EFCT_QWORD_FIELD(*p_event, ESF_HZ_EV_TSYNC_TIME_HIGH_48);
| ^~~~~~~~~~~~~~~~
drivers/net/ethernet/amd/efct/efct_bitfield.h:69:22: warning: left shift count >= width of type [-Wshift-count-overflow]
69 | (((((u32)1) << (width))) - 1))
| ^~
drivers/net/ethernet/amd/efct/efct_bitfield.h:145:10: note: in expansion of macro 'EFCT_MASK32'
145 | EFCT_MASK32((high) + 1 - (low)))
| ^~~~~~~~~~~
drivers/net/ethernet/amd/efct/efct_bitfield.h:164:9: note: in expansion of macro 'EFCT_EXTRACT_QWORD32'
164 | EFCT_EXTRACT_QWORD32(qword, EFCT_LOW_BIT(field), \
| ^~~~~~~~~~~~~~~~~~~~
drivers/net/ethernet/amd/efct/efct_bitfield.h:212:41: note: in expansion of macro 'EFCT_QWORD_FIELD32'
212 | #define EFCT_QWORD_FIELD EFCT_QWORD_FIELD32
| ^~~~~~~~~~~~~~~~~~
drivers/net/ethernet/amd/efct/efct_nic.c:746:38: note: in expansion of macro 'EFCT_QWORD_FIELD'
746 | evq->sync_timestamp_major = EFCT_QWORD_FIELD(*p_event, ESF_HZ_EV_TSYNC_TIME_HIGH_48);
| ^~~~~~~~~~~~~~~~ cc1: some warnings being treated as errors
--
In file included from drivers/net/ethernet/amd/efct/efct_tx.c:11:
drivers/net/ethernet/amd/efct/efct_io.h: In function '_efct_writeq':
>> drivers/net/ethernet/amd/efct/efct_io.h:57:9: error: implicit declaration of function '__raw_writeq'; did you mean '_efct_writeq'? [-Werror=implicit-function-declaration]
57 | __raw_writeq((__force u64)value, reg);
| ^~~~~~~~~~~~
| _efct_writeq
drivers/net/ethernet/amd/efct/efct_io.h: In function '_efct_readq':
>> drivers/net/ethernet/amd/efct/efct_io.h:62:32: error: implicit declaration of function '__raw_readq' [-Werror=implicit-function-declaration]
62 | return (__force __le64)__raw_readq(reg);
| ^~~~~~~~~~~
drivers/net/ethernet/amd/efct/efct_tx.c: In function 'txq_piobuf_w64':
>> drivers/net/ethernet/amd/efct/efct_tx.c:89:9: error: implicit declaration of function 'writeq'; did you mean 'writel'? [-Werror=implicit-function-declaration]
89 | writeq(val, dest64);
| ^~~~~~
| writel
In file included from drivers/net/ethernet/amd/efct/efct_driver.h:25,
from drivers/net/ethernet/amd/efct/efct_tx.h:11,
from drivers/net/ethernet/amd/efct/efct_tx.c:9:
drivers/net/ethernet/amd/efct/efct_tx.c: In function 'efct_ev_tx':
drivers/net/ethernet/amd/efct/efct_bitfield.h:112:27: warning: left shift count >= width of type [-Wshift-count-overflow]
112 | (native_element) << ((min) - (low)))
| ^~
drivers/net/ethernet/amd/efct/efct_bitfield.h:124:9: note: in expansion of macro 'EFCT_EXTRACT_NATIVE'
124 | EFCT_EXTRACT_NATIVE(le32_to_cpu(element), min, max, low, high)
| ^~~~~~~~~~~~~~~~~~~
drivers/net/ethernet/amd/efct/efct_bitfield.h:144:11: note: in expansion of macro 'EFCT_EXTRACT32'
144 | EFCT_EXTRACT32((qword).u32[1], 32, 63, low, high)) & \
| ^~~~~~~~~~~~~~
drivers/net/ethernet/amd/efct/efct_bitfield.h:164:9: note: in expansion of macro 'EFCT_EXTRACT_QWORD32'
164 | EFCT_EXTRACT_QWORD32(qword, EFCT_LOW_BIT(field), \
| ^~~~~~~~~~~~~~~~~~~~
drivers/net/ethernet/amd/efct/efct_bitfield.h:212:41: note: in expansion of macro 'EFCT_QWORD_FIELD32'
212 | #define EFCT_QWORD_FIELD EFCT_QWORD_FIELD32
| ^~~~~~~~~~~~~~~~~~
drivers/net/ethernet/amd/efct/efct_tx.c:326:22: note: in expansion of macro 'EFCT_QWORD_FIELD'
326 | partial_ts = EFCT_QWORD_FIELD(*p_event, ESF_HZ_EV_TXCMPL_PARTIAL_TSTAMP);
| ^~~~~~~~~~~~~~~~
drivers/net/ethernet/amd/efct/efct_bitfield.h:69:22: warning: left shift count >= width of type [-Wshift-count-overflow]
69 | (((((u32)1) << (width))) - 1))
| ^~
drivers/net/ethernet/amd/efct/efct_bitfield.h:145:10: note: in expansion of macro 'EFCT_MASK32'
145 | EFCT_MASK32((high) + 1 - (low)))
| ^~~~~~~~~~~
drivers/net/ethernet/amd/efct/efct_bitfield.h:164:9: note: in expansion of macro 'EFCT_EXTRACT_QWORD32'
164 | EFCT_EXTRACT_QWORD32(qword, EFCT_LOW_BIT(field), \
| ^~~~~~~~~~~~~~~~~~~~
drivers/net/ethernet/amd/efct/efct_bitfield.h:212:41: note: in expansion of macro 'EFCT_QWORD_FIELD32'
212 | #define EFCT_QWORD_FIELD EFCT_QWORD_FIELD32
| ^~~~~~~~~~~~~~~~~~
drivers/net/ethernet/amd/efct/efct_tx.c:326:22: note: in expansion of macro 'EFCT_QWORD_FIELD'
326 | partial_ts = EFCT_QWORD_FIELD(*p_event, ESF_HZ_EV_TXCMPL_PARTIAL_TSTAMP);
| ^~~~~~~~~~~~~~~~ cc1: some warnings being treated as errors
--
In file included from drivers/net/ethernet/amd/efct/efct_rx.c:15:
drivers/net/ethernet/amd/efct/efct_io.h: In function '_efct_writeq':
>> drivers/net/ethernet/amd/efct/efct_io.h:57:9: error: implicit declaration of function '__raw_writeq'; did you mean '_efct_writeq'? [-Werror=implicit-function-declaration]
57 | __raw_writeq((__force u64)value, reg);
| ^~~~~~~~~~~~
| _efct_writeq
drivers/net/ethernet/amd/efct/efct_io.h: In function '_efct_readq':
>> drivers/net/ethernet/amd/efct/efct_io.h:62:32: error: implicit declaration of function '__raw_readq' [-Werror=implicit-function-declaration]
62 | return (__force __le64)__raw_readq(reg);
| ^~~~~~~~~~~
In file included from drivers/net/ethernet/amd/efct/efct_driver.h:25,
from drivers/net/ethernet/amd/efct/efct_rx.h:11,
from drivers/net/ethernet/amd/efct/efct_rx.c:12:
drivers/net/ethernet/amd/efct/efct_rx.c: In function 'efct_include_ts_in_rxskb':
drivers/net/ethernet/amd/efct/efct_bitfield.h:112:27: warning: left shift count >= width of type [-Wshift-count-overflow]
112 | (native_element) << ((min) - (low)))
| ^~
drivers/net/ethernet/amd/efct/efct_bitfield.h:124:9: note: in expansion of macro 'EFCT_EXTRACT_NATIVE'
124 | EFCT_EXTRACT_NATIVE(le32_to_cpu(element), min, max, low, high)
| ^~~~~~~~~~~~~~~~~~~
drivers/net/ethernet/amd/efct/efct_bitfield.h:139:11: note: in expansion of macro 'EFCT_EXTRACT32'
139 | EFCT_EXTRACT32((oword).u32[3], 96, 127, low, high)) & \
| ^~~~~~~~~~~~~~
drivers/net/ethernet/amd/efct/efct_bitfield.h:160:9: note: in expansion of macro 'EFCT_EXTRACT_OWORD32'
160 | EFCT_EXTRACT_OWORD32(oword, EFCT_LOW_BIT(field), \
| ^~~~~~~~~~~~~~~~~~~~
drivers/net/ethernet/amd/efct/efct_bitfield.h:211:41: note: in expansion of macro 'EFCT_OWORD_FIELD32'
211 | #define EFCT_OWORD_FIELD EFCT_OWORD_FIELD32
| ^~~~~~~~~~~~~~~~~~
drivers/net/ethernet/amd/efct/efct_rx.c:386:24: note: in expansion of macro 'EFCT_OWORD_FIELD'
386 | pkt_ts_major = EFCT_OWORD_FIELD(*((union efct_oword *)p_meta), ESF_HZ_RX_PREFIX_TIMESTAMP);
| ^~~~~~~~~~~~~~~~
drivers/net/ethernet/amd/efct/efct_bitfield.h:69:22: warning: left shift count >= width of type [-Wshift-count-overflow]
69 | (((((u32)1) << (width))) - 1))
| ^~
drivers/net/ethernet/amd/efct/efct_bitfield.h:140:10: note: in expansion of macro 'EFCT_MASK32'
140 | EFCT_MASK32((high) + 1 - (low)))
| ^~~~~~~~~~~
drivers/net/ethernet/amd/efct/efct_bitfield.h:160:9: note: in expansion of macro 'EFCT_EXTRACT_OWORD32'
160 | EFCT_EXTRACT_OWORD32(oword, EFCT_LOW_BIT(field), \
| ^~~~~~~~~~~~~~~~~~~~
drivers/net/ethernet/amd/efct/efct_bitfield.h:211:41: note: in expansion of macro 'EFCT_OWORD_FIELD32'
211 | #define EFCT_OWORD_FIELD EFCT_OWORD_FIELD32
| ^~~~~~~~~~~~~~~~~~
drivers/net/ethernet/amd/efct/efct_rx.c:386:24: note: in expansion of macro 'EFCT_OWORD_FIELD'
386 | pkt_ts_major = EFCT_OWORD_FIELD(*((union efct_oword *)p_meta), ESF_HZ_RX_PREFIX_TIMESTAMP);
| ^~~~~~~~~~~~~~~~cc1: some warnings being treated as errors
vim +57 drivers/net/ethernet/amd/efct/efct_io.h
83f06a5b784384 Harsh Jain 2023-02-10 54
83f06a5b784384 Harsh Jain 2023-02-10 55 static inline void _efct_writeq(__le64 value, void __iomem *reg)
83f06a5b784384 Harsh Jain 2023-02-10 56 {
83f06a5b784384 Harsh Jain 2023-02-10 @57 __raw_writeq((__force u64)value, reg);
83f06a5b784384 Harsh Jain 2023-02-10 58 }
83f06a5b784384 Harsh Jain 2023-02-10 59
83f06a5b784384 Harsh Jain 2023-02-10 60 static inline __le64 _efct_readq(void __iomem *reg)
83f06a5b784384 Harsh Jain 2023-02-10 61 {83f06a5b784384 Harsh Jain 2023-02-10 @62 return (__force __le64)__raw_readq(reg);
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests
kernel test robot
build botRe: [PATCH 6/6] net: ethernet: efct: Add maintainer, kconfig, makefile
In reply to Harsh JainI love your patch! Perhaps something to improve:
Hi Harsh,
I love your patch! Perhaps something to improve:
[auto build test WARNING on net-next/master]
[also build test WARNING on net/master horms-ipvs/master linus/master v6.2-rc8 next-20230213] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Harsh-Jain/net-ethernet-efct-New-X3-net-driver/20230210-210711 patch link: https://lore.kernel.org/r/20230210130321.2898-7-h.jain%40amd.com patch subject: [PATCH 6/6] net: ethernet: efct: Add maintainer, kconfig, makefile config: alpha-randconfig-s042-20230212 (https://download.01.org/0day-ci/archive/20230214/[email protected]/config) compiler: alpha-linux-gcc (GCC) 12.1.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# apt-get install sparse
# sparse version: v0.6.4-39-gce1a6720-dirty
# https://github.com/intel-lab-lkp/linux/commit/93ed306161ac0259bd72b14922a7f6af60b3748c
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Harsh-Jain/net-ethernet-efct-New-X3-net-driver/20230210-210711
git checkout 93ed306161ac0259bd72b14922a7f6af60b3748c
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=alpha olddefconfig COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=alpha SHELL=/bin/bash drivers/net/
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>
| Link: https://lore.kernel.org/oe-kbuild-all/[email protected]/
sparse warnings: (new ones prefixed by >>)
drivers/net/ethernet/amd/efct/efct_pci.c: note: in included file:
>> drivers/net/ethernet/amd/efct/efct_io.h:48:54: sparse: sparse: cast removes address space '__iomem' of expression >> drivers/net/ethernet/amd/efct/efct_io.h:48:63: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const volatile [noderef] __iomem *addr @@ got unsigned char [usertype] * @@
drivers/net/ethernet/amd/efct/efct_io.h:48:63: sparse: expected void const volatile [noderef] __iomem *addr
drivers/net/ethernet/amd/efct/efct_io.h:48:63: sparse: got unsigned char [usertype] *
drivers/net/ethernet/amd/efct/efct_io.h:49:54: sparse: sparse: cast removes address space '__iomem' of expression
drivers/net/ethernet/amd/efct/efct_io.h:49:63: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const volatile [noderef] __iomem *addr @@ got unsigned char [usertype] * @@
drivers/net/ethernet/amd/efct/efct_io.h:49:63: sparse: expected void const volatile [noderef] __iomem *addr
drivers/net/ethernet/amd/efct/efct_io.h:49:63: sparse: got unsigned char [usertype] *
drivers/net/ethernet/amd/efct/efct_io.h:50:54: sparse: sparse: cast removes address space '__iomem' of expression
drivers/net/ethernet/amd/efct/efct_io.h:50:63: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const volatile [noderef] __iomem *addr @@ got unsigned char [usertype] * @@
drivers/net/ethernet/amd/efct/efct_io.h:50:63: sparse: expected void const volatile [noderef] __iomem *addr
drivers/net/ethernet/amd/efct/efct_io.h:50:63: sparse: got unsigned char [usertype] *
drivers/net/ethernet/amd/efct/efct_io.h:51:54: sparse: sparse: cast removes address space '__iomem' of expression
drivers/net/ethernet/amd/efct/efct_io.h:51:63: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const volatile [noderef] __iomem *addr @@ got unsigned char [usertype] * @@
drivers/net/ethernet/amd/efct/efct_io.h:51:63: sparse: expected void const volatile [noderef] __iomem *addr
drivers/net/ethernet/amd/efct/efct_io.h:51:63: sparse: got unsigned char [usertype] *
vim +/__iomem +48 drivers/net/ethernet/amd/efct/efct_io.h
83f06a5b784384 Harsh Jain 2023-02-10 40
83f06a5b784384 Harsh Jain 2023-02-10 41 /* Read a 128-bit CSR, locking as appropriate. */
83f06a5b784384 Harsh Jain 2023-02-10 42 static inline void efct_reado(struct efct_device *efct_dev,
83f06a5b784384 Harsh Jain 2023-02-10 43 union efct_oword *value, void __iomem *reg)
83f06a5b784384 Harsh Jain 2023-02-10 44 {
83f06a5b784384 Harsh Jain 2023-02-10 45 unsigned long flags __maybe_unused;
83f06a5b784384 Harsh Jain 2023-02-10 46
83f06a5b784384 Harsh Jain 2023-02-10 47 spin_lock_irqsave(&efct_dev->biu_lock, flags);
83f06a5b784384 Harsh Jain 2023-02-10 @48 value->u32[0] = (__force __le32)__raw_readl((u8 *)reg + 0);
83f06a5b784384 Harsh Jain 2023-02-10 49 value->u32[1] = (__force __le32)__raw_readl((u8 *)reg + 4);
83f06a5b784384 Harsh Jain 2023-02-10 50 value->u32[2] = (__force __le32)__raw_readl((u8 *)reg + 8);
83f06a5b784384 Harsh Jain 2023-02-10 51 value->u32[3] = (__force __le32)__raw_readl((u8 *)reg + 12);
83f06a5b784384 Harsh Jain 2023-02-10 52 spin_unlock_irqrestore(&efct_dev->biu_lock, flags);
83f06a5b784384 Harsh Jain 2023-02-10 53 }83f06a5b784384 Harsh Jain 2023-02-10 54
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests
kernel test robot
build botRe: [PATCH 6/6] net: ethernet: efct: Add maintainer, kconfig, makefile
In reply to Harsh JainI love your patch! Perhaps something to improve:
Hi Harsh,
I love your patch! Perhaps something to improve:
[auto build test WARNING on net-next/master]
[also build test WARNING on net/master horms-ipvs/master linus/master v6.2-rc8 next-20230214] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Harsh-Jain/net-ethernet-efct-New-X3-net-driver/20230210-210711 patch link: https://lore.kernel.org/r/20230210130321.2898-7-h.jain%40amd.com patch subject: [PATCH 6/6] net: ethernet: efct: Add maintainer, kconfig, makefile config: riscv-kismet-CONFIG_PTP_1588_CLOCK-CONFIG_EFCT_PTP-0-0 (https://download.01.org/0day-ci/archive/20230214/[email protected]/config)
reproduce:
# https://github.com/intel-lab-lkp/linux/commit/93ed306161ac0259bd72b14922a7f6af60b3748c
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Harsh-Jain/net-ethernet-efct-New-X3-net-driver/20230210-210711 git checkout 93ed306161ac0259bd72b14922a7f6af60b3748c
# 1. reproduce by kismet
# install kmax per https://github.com/paulgazz/kmax/blob/master/README.md
kismet --linux-ksrc=linux --selectees CONFIG_PTP_1588_CLOCK --selectors CONFIG_EFCT_PTP -a=riscv
# 2. reproduce by make
# save the config file to linux source tree
cd linux
make ARCH=riscv olddefconfig
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>
| Link: https://lore.kernel.org/oe-kbuild-all/[email protected]/
kismet warnings: (new ones prefixed by >>)
>> kismet: WARNING: unmet direct dependencies detected for PTP_1588_CLOCK when selected by EFCT_PTP
WARNING: unmet direct dependencies detected for PTP_1588_CLOCK
Depends on [n]: NET [=y] && POSIX_TIMERS [=n]
Selected by [y]:
- EFCT_PTP [=y] && NETDEVICES [=y] && ETHERNET [=y] && NET_VENDOR_AMD [=y] && EFCT [=y]
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests
Jakub Kicinski
maintainerQuoted 4 lines · On Fri, 10 Feb 2023 18:33:15 +0530 Harsh Jain wrote:
This patch series adds new ethernet network driver for Alveo X3522[1]. X3 is a low-latency NIC with an aim to deliver the lowest possible latency. It accelerates a range of diverse trading strategies and financial applications.
Please get this reviewed by people within AMD who know something about netdev. Ed, Martin, Alejandro, etc.. This driver seems to share similarities with SFC and you haven't even CCed them.
This pile a 23kLoC has the same issues the community has been raising in reviews of other drivers from your organization. We don't have the resources to be engaging with badly behaving, throw-the-code-over-the-wall-open-source vendors.
Quoted 18 lines
-----Original Message-----
From: Jakub Kicinski <[email protected]>
Sent: Saturday, February 11, 2023 12:52 AM
To: Jain, Harsh (DCG-ENG) <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Lendacky, Thomas <[email protected]>; Rangoju, Raju <[email protected]>; S-k, Shyam-sundar <[email protected]>; [email protected]; Gangurde, Abhijit <[email protected]>; Gupta, Puneet (DCG-ENG) <[email protected]>; Agarwal, Nikhil <[email protected]>; Reddy, tarak <[email protected]>; [email protected]
Subject: Re: [PATCH 0/6] net: ethernet: efct Add x3 ethernet driverQuoted 4 lines · On Fri, 10 Feb 2023 18:33:15 +0530 Harsh Jain wrote:
This patch series adds new ethernet network driver for Alveo X3522[1]. X3 is a low-latency NIC with an aim to deliver the lowest possible latency. It accelerates a range of diverse trading strategies and financial applications.
Quoted 8 lines
Please get this reviewed by people within AMD who know something about netdev. Ed, Martin, Alejandro, etc.. This driver seems to share similarities with SFC and you haven't even CCed them.
This pile a 23kLoC has the same issues the community has been raising in reviews of other drivers from your organization. We don't have the resources to be engaging with badly behaving, throw-the-code-over-the-wall-open-source vendors.
Thanks Jakub,
We will review this internally and get back with a new approach.