mfd: intel-m10-bmc: add sysfs files for mac_address
Subsystems (2)
cover mfd: intel-m10-bmc: add sysfs files for mac_address
Add two sysfs nodes to the Intel MAX10 BMC driver: mac_address and mac_count. The mac_address provides the first of a series of sequential MAC addresses assigned to the FPGA card. The mac_count indicates how many MAC addresses are assigned to the card.
Russ Weight (1):
mfd: intel-m10-bmc: expose mac address and count
.../ABI/testing/sysfs-driver-intel-m10-bmc | 20 +++++++++ drivers/mfd/intel-m10-bmc.c | 43 +++++++++++++++++++ include/linux/mfd/intel-m10-bmc.h | 9 ++++ 3 files changed, 72 insertions(+)
Signature · 1 line
2.25.1
PATCH 1/1 mfd: intel-m10-bmc: expose mac address and count
Create two sysfs entries for exposing the MAC address and count from the MAX10 BMC register space.
--- .../ABI/testing/sysfs-driver-intel-m10-bmc | 20 +++++++++ drivers/mfd/intel-m10-bmc.c | 43 +++++++++++++++++++ include/linux/mfd/intel-m10-bmc.h | 9 ++++ 3 files changed, 72 insertions(+)
Documentation/ABI/testing/sysfs-driver-intel-m10-bmc +20 -0
@@ -13,3 +13,23 @@ Contact: Xu Yilun <[email protected]> Description: Read only. Returns the firmware version of Intel MAX10 BMC chip. Format: "0x%x". + +What: /sys/bus/spi/devices/.../mac_address +Date: December 2020 +KernelVersion: 5.11 +Contact: Russ Weight <[email protected]> +Description: Read only. Returns the base mac address assigned to + the board managed by the Intel MAX10 BMC. It is + stored in flash and is mirrored in the MAX10 BMC + register space. + Format: "%02x:%02x:%02x:%02x:%02x:%02x". + +What: /sys/bus/spi/devices/.../mac_count +Date: December 2020 +KernelVersion: 5.11 +Contact: Russ Weight <[email protected]> +Description: Read only. Returns the number of mac addresses + assigned to the board managed by the Intel MAX10 + BMC. This value is stored in flash and is mirrored + in the MAX10 BMC register space. + Format: "%u".
drivers/mfd/intel-m10-bmc.c +43 -0
52 lines not on this page · raw message
include/linux/mfd/intel-m10-bmc.h +9 -0
@@ -15,6 +15,15 @@/* Register offset of system registers */ #define NIOS2_FW_VERSION 0x0 +#define M10BMC_MACADDR1 0x10 +#define M10BMC_MAC_BYTE4 GENMASK(7, 0) +#define M10BMC_MAC_BYTE3 GENMASK(15, 8) +#define M10BMC_MAC_BYTE2 GENMASK(23, 16) +#define M10BMC_MAC_BYTE1 GENMASK(31, 24) +#define M10BMC_MACADDR2 0x14 +#define M10BMC_MAC_BYTE6 GENMASK(7, 0) +#define M10BMC_MAC_BYTE5 GENMASK(15, 8) +#define M10BMC_MAC_COUNT GENMASK(23, 16)#define M10BMC_TEST_REG 0x3c#define M10BMC_BUILD_VER 0x68#define M10BMC_VER_MAJOR_MSK GENMASK(23, 16)
Signature · 1 line
2.25.1
Tom Rix
reviewerRe: [PATCH v1 1/1] mfd: intel-m10-bmc: expose mac address and count
Quoted 52 lines · Russ Weight
Create two sysfs entries for exposing the MAC address and count from the MAX10 BMC register space.
Signed-off-by Russ Weight <[email protected]>Signed-off-by Xu Yilun <[email protected]>--- .../ABI/testing/sysfs-driver-intel-m10-bmc | 20 +++++++++ drivers/mfd/intel-m10-bmc.c | 43 +++++++++++++++++++ include/linux/mfd/intel-m10-bmc.h | 9 ++++ 3 files changed, 72 insertions(+)Documentation/ABI/testing/sysfs-driver-intel-m10-bmc +20
-0@@ -13,3 +13,23 @@ Contact: Xu Yilun <[email protected]> Description: Read only. Returns the firmware version of Intel MAX10 BMC chip. Format: "0x%x". + +What: /sys/bus/spi/devices/.../mac_address +Date: December 2020 +KernelVersion: 5.11 +Contact: Russ Weight <[email protected]> +Description: Read only. Returns the base mac address assigned to + the board managed by the Intel MAX10 BMC. It is + stored in flash and is mirrored in the MAX10 BMC + register space. + Format: "%02x:%02x:%02x:%02x:%02x:%02x". + +What: /sys/bus/spi/devices/.../mac_count +Date: December 2020 +KernelVersion: 5.11 +Contact: Russ Weight <[email protected]> +Description: Read only. Returns the number of mac addresses + assigned to the board managed by the Intel MAX10 + BMC. This value is stored in flash and is mirrored + in the MAX10 BMC register space. + Format: "%u".drivers/mfd/intel-m10-bmc.c +5
-0@@ -60,9 +60,52 @@ static ssize_t bmcfw_version_show(struct device *dev, }static DEVICE_ATTR_RO (bmcfw_version); +static ssize_t mac_address_show (struct device *dev, +struct device_attribute *attr,char *buf) +{ +struct intel_m10bmc *max10 =dev_get_drvdata (dev); +unsigned int macaddr1, macaddr2;
drivers/mfd/intel-m10-bmc.c static ssize_t bmcfw_version_show(struct device *dev, · line 77
Quoted 10 lines
drivers/mfd/intel-m10-bmc.c +10
-0+int ret; + + ret =m10bmc_sys_read (max10,M10BMC_MACADDR1 , &macaddr1); +if (ret) +return ret; + + ret =m10bmc_sys_read (max10,M10BMC_MACADDR2 , &macaddr2); +if (ret) +return ret; +
The mac_count implies there are more than 1 mac address.
This logic looks like could only do one.
How are the 2nd, 3rd etc. mac addresses found ?
drivers/mfd/intel-m10-bmc.c static ssize_t bmcfw_version_show(struct device *dev, · line 84
Quoted 7 lines
drivers/mfd/intel-m10-bmc.c +7
-0+return sprintf (buf,"%02x:%02x:%02x:%02x:%02x:%02x\n" , + (u8 )FIELD_GET (M10BMC_MAC_BYTE1 , macaddr1), + (u8 )FIELD_GET (M10BMC_MAC_BYTE2 , macaddr1), + (u8 )FIELD_GET (M10BMC_MAC_BYTE3 , macaddr1), + (u8 )FIELD_GET (M10BMC_MAC_BYTE4 , macaddr1), + (u8 )FIELD_GET (M10BMC_MAC_BYTE5 , macaddr2), + (u8 )FIELD_GET (M10BMC_MAC_BYTE6 , macaddr2));
consider using sysfs_emit over sprintf
Tom
Quoted 47 lines
drivers/mfd/intel-m10-bmc.c +21
-0+} +static DEVICE_ATTR_RO (mac_address); + +static ssize_t mac_count_show (struct device *dev, +struct device_attribute *attr,char *buf) +{ +struct intel_m10bmc *max10 =dev_get_drvdata (dev); +unsigned int macaddr2; +int ret; + + ret =m10bmc_sys_read (max10,M10BMC_MACADDR2 , &macaddr2); +if (ret) +return ret; + +return sprintf (buf,"%u\n" , + (u8 )FIELD_GET (M10BMC_MAC_COUNT , macaddr2)); +} +static DEVICE_ATTR_RO (mac_count); +static struct attribute *m10bmc_attrs[] = { &dev_attr_bmc_version.attr, &dev_attr_bmcfw_version.attr, + &dev_attr_mac_address.attr, + &dev_attr_mac_count.attr,NULL , };ATTRIBUTE_GROUPS (m10bmc);include/linux/mfd/intel-m10-bmc.h +9
-0@@ -15,6 +15,15 @@/* Register offset of system registers */ #define NIOS2_FW_VERSION 0x0 +#define M10BMC_MACADDR1 0x10 +#define M10BMC_MAC_BYTE4 GENMASK(7, 0) +#define M10BMC_MAC_BYTE3 GENMASK(15, 8) +#define M10BMC_MAC_BYTE2 GENMASK(23, 16) +#define M10BMC_MAC_BYTE1 GENMASK(31, 24) +#define M10BMC_MACADDR2 0x14 +#define M10BMC_MAC_BYTE6 GENMASK(7, 0) +#define M10BMC_MAC_BYTE5 GENMASK(15, 8) +#define M10BMC_MAC_COUNT GENMASK(23, 16)#define M10BMC_TEST_REG 0x3c#define M10BMC_BUILD_VER 0x68#define M10BMC_VER_MAJOR_MSK GENMASK(23, 16)
Re: [PATCH v1 1/1] mfd: intel-m10-bmc: expose mac address and count
Quoted 65 lines · Tom Rix
Quoted 52 lines · Russ Weight
Create two sysfs entries for exposing the MAC address and count from the MAX10 BMC register space.
Signed-off-by Russ Weight <[email protected]>Signed-off-by Xu Yilun <[email protected]>--- .../ABI/testing/sysfs-driver-intel-m10-bmc | 20 +++++++++ drivers/mfd/intel-m10-bmc.c | 43 +++++++++++++++++++ include/linux/mfd/intel-m10-bmc.h | 9 ++++ 3 files changed, 72 insertions(+)Documentation/ABI/testing/sysfs-driver-intel-m10-bmc +20
-0@@ -13,3 +13,23 @@ Contact: Xu Yilun <[email protected]> Description: Read only. Returns the firmware version of Intel MAX10 BMC chip. Format: "0x%x". + +What: /sys/bus/spi/devices/.../mac_address +Date: December 2020 +KernelVersion: 5.11 +Contact: Russ Weight <[email protected]> +Description: Read only. Returns the base mac address assigned to + the board managed by the Intel MAX10 BMC. It is + stored in flash and is mirrored in the MAX10 BMC + register space. + Format: "%02x:%02x:%02x:%02x:%02x:%02x". + +What: /sys/bus/spi/devices/.../mac_count +Date: December 2020 +KernelVersion: 5.11 +Contact: Russ Weight <[email protected]> +Description: Read only. Returns the number of mac addresses + assigned to the board managed by the Intel MAX10 + BMC. This value is stored in flash and is mirrored + in the MAX10 BMC register space. + Format: "%u".drivers/mfd/intel-m10-bmc.c +5
-0@@ -60,9 +60,52 @@ static ssize_t bmcfw_version_show(struct device *dev, }static DEVICE_ATTR_RO (bmcfw_version); +static ssize_t mac_address_show (struct device *dev, +struct device_attribute *attr,char *buf) +{ +struct intel_m10bmc *max10 =dev_get_drvdata (dev); +unsigned int macaddr1, macaddr2;drivers/mfd/intel-m10-bmc.c static ssize_t bmcfw_version_show(struct device *dev, · line 77
Quoted 10 lines
drivers/mfd/intel-m10-bmc.c +10
-0+int ret; + + ret =m10bmc_sys_read (max10,M10BMC_MACADDR1 , &macaddr1); +if (ret) +return ret; + + ret =m10bmc_sys_read (max10,M10BMC_MACADDR2 , &macaddr2); +if (ret) +return ret; +The
mac_countimplies there are more than 1 mac address.
Quoted 3 lines
This logic looks like could only do one.
How are the 2nd, 3rd etc. mac addresses found ?
The MAC addresses assigned to the card are sequential. The base MAC address is exposed through the mac_address sysfs entry. Add 1 to that MAC address for the second MAC address, etc.
Quoted 9 lines
drivers/mfd/intel-m10-bmc.c static ssize_t bmcfw_version_show(struct device *dev, · line 84
Quoted 8 lines
drivers/mfd/intel-m10-bmc.c +7
-0+return sprintf (buf,"%02x:%02x:%02x:%02x:%02x:%02x\n" , + (u8 )FIELD_GET (M10BMC_MAC_BYTE1 , macaddr1), + (u8 )FIELD_GET (M10BMC_MAC_BYTE2 , macaddr1), + (u8 )FIELD_GET (M10BMC_MAC_BYTE3 , macaddr1), + (u8 )FIELD_GET (M10BMC_MAC_BYTE4 , macaddr1), + (u8 )FIELD_GET (M10BMC_MAC_BYTE5 , macaddr2), + (u8 )FIELD_GET (M10BMC_MAC_BYTE6 , macaddr2));consider using
sysfs_emitover sprintf
Yes. I'll change to sysfs_emit and resubmit.
Thanks,
- Russ
Quoted 50 lines
Tom
Quoted 47 lines
drivers/mfd/intel-m10-bmc.c +21
-0+} +static DEVICE_ATTR_RO (mac_address); + +static ssize_t mac_count_show (struct device *dev, +struct device_attribute *attr,char *buf) +{ +struct intel_m10bmc *max10 =dev_get_drvdata (dev); +unsigned int macaddr2; +int ret; + + ret =m10bmc_sys_read (max10,M10BMC_MACADDR2 , &macaddr2); +if (ret) +return ret; + +return sprintf (buf,"%u\n" , + (u8 )FIELD_GET (M10BMC_MAC_COUNT , macaddr2)); +} +static DEVICE_ATTR_RO (mac_count); +static struct attribute *m10bmc_attrs[] = { &dev_attr_bmc_version.attr, &dev_attr_bmcfw_version.attr, + &dev_attr_mac_address.attr, + &dev_attr_mac_count.attr,NULL , };ATTRIBUTE_GROUPS (m10bmc);include/linux/mfd/intel-m10-bmc.h +9
-0@@ -15,6 +15,15 @@/* Register offset of system registers */ #define NIOS2_FW_VERSION 0x0 +#define M10BMC_MACADDR1 0x10 +#define M10BMC_MAC_BYTE4 GENMASK(7, 0) +#define M10BMC_MAC_BYTE3 GENMASK(15, 8) +#define M10BMC_MAC_BYTE2 GENMASK(23, 16) +#define M10BMC_MAC_BYTE1 GENMASK(31, 24) +#define M10BMC_MACADDR2 0x14 +#define M10BMC_MAC_BYTE6 GENMASK(7, 0) +#define M10BMC_MAC_BYTE5 GENMASK(15, 8) +#define M10BMC_MAC_COUNT GENMASK(23, 16)#define M10BMC_TEST_REG 0x3c#define M10BMC_BUILD_VER 0x68#define M10BMC_VER_MAJOR_MSK GENMASK(23, 16)
Tom Rix
reviewerRe: [PATCH v1 1/1] mfd: intel-m10-bmc: expose mac address and count
Quoted 67 lines · Russ Weight
Quoted 65 lines · Tom Rix
Quoted 52 lines · Russ Weight
Create two sysfs entries for exposing the MAC address and count from the MAX10 BMC register space.
Signed-off-by Russ Weight <[email protected]>Signed-off-by Xu Yilun <[email protected]>--- .../ABI/testing/sysfs-driver-intel-m10-bmc | 20 +++++++++ drivers/mfd/intel-m10-bmc.c | 43 +++++++++++++++++++ include/linux/mfd/intel-m10-bmc.h | 9 ++++ 3 files changed, 72 insertions(+)Documentation/ABI/testing/sysfs-driver-intel-m10-bmc +20
-0@@ -13,3 +13,23 @@ Contact: Xu Yilun <[email protected]> Description: Read only. Returns the firmware version of Intel MAX10 BMC chip. Format: "0x%x". + +What: /sys/bus/spi/devices/.../mac_address +Date: December 2020 +KernelVersion: 5.11 +Contact: Russ Weight <[email protected]> +Description: Read only. Returns the base mac address assigned to + the board managed by the Intel MAX10 BMC. It is + stored in flash and is mirrored in the MAX10 BMC + register space. + Format: "%02x:%02x:%02x:%02x:%02x:%02x". + +What: /sys/bus/spi/devices/.../mac_count +Date: December 2020 +KernelVersion: 5.11 +Contact: Russ Weight <[email protected]> +Description: Read only. Returns the number of mac addresses + assigned to the board managed by the Intel MAX10 + BMC. This value is stored in flash and is mirrored + in the MAX10 BMC register space. + Format: "%u".drivers/mfd/intel-m10-bmc.c +5
-0@@ -60,9 +60,52 @@ static ssize_t bmcfw_version_show(struct device *dev, }static DEVICE_ATTR_RO (bmcfw_version); +static ssize_t mac_address_show (struct device *dev, +struct device_attribute *attr,char *buf) +{ +struct intel_m10bmc *max10 =dev_get_drvdata (dev); +unsigned int macaddr1, macaddr2;drivers/mfd/intel-m10-bmc.c static ssize_t bmcfw_version_show(struct device *dev, · line 77
Quoted 10 lines
drivers/mfd/intel-m10-bmc.c +10
-0+int ret; + + ret =m10bmc_sys_read (max10,M10BMC_MACADDR1 , &macaddr1); +if (ret) +return ret; + + ret =m10bmc_sys_read (max10,M10BMC_MACADDR2 , &macaddr2); +if (ret) +return ret; +The
mac_countimplies there are more than 1 mac address.
Quoted 6 lines
Quoted 3 lines
This logic looks like could only do one.
How are the 2nd, 3rd etc. mac addresses found ?
The MAC addresses assigned to the card are sequential. The base MAC address is exposed through the
mac_addresssysfs entry. Add 1 to that MAC address for the second MAC address, etc.
Ok.
Please capture this in the docs section above.
Quoted 61 lines
Quoted 8 lines
drivers/mfd/intel-m10-bmc.c static ssize_t bmcfw_version_show(struct device *dev, · line 84
Quoted 7 lines
drivers/mfd/intel-m10-bmc.c +7
-0+return sprintf (buf,"%02x:%02x:%02x:%02x:%02x:%02x\n" , + (u8 )FIELD_GET (M10BMC_MAC_BYTE1 , macaddr1), + (u8 )FIELD_GET (M10BMC_MAC_BYTE2 , macaddr1), + (u8 )FIELD_GET (M10BMC_MAC_BYTE3 , macaddr1), + (u8 )FIELD_GET (M10BMC_MAC_BYTE4 , macaddr1), + (u8 )FIELD_GET (M10BMC_MAC_BYTE5 , macaddr2), + (u8 )FIELD_GET (M10BMC_MAC_BYTE6 , macaddr2));consider using
sysfs_emitover sprintfYes. I'll change to
sysfs_emitand resubmit.Thanks,
- RussQuoted 49 lines
Tom
Quoted 47 lines
drivers/mfd/intel-m10-bmc.c +21
-0+} +static DEVICE_ATTR_RO (mac_address); + +static ssize_t mac_count_show (struct device *dev, +struct device_attribute *attr,char *buf) +{ +struct intel_m10bmc *max10 =dev_get_drvdata (dev); +unsigned int macaddr2; +int ret; + + ret =m10bmc_sys_read (max10,M10BMC_MACADDR2 , &macaddr2); +if (ret) +return ret; + +return sprintf (buf,"%u\n" , + (u8 )FIELD_GET (M10BMC_MAC_COUNT , macaddr2)); +} +static DEVICE_ATTR_RO (mac_count); +static struct attribute *m10bmc_attrs[] = { &dev_attr_bmc_version.attr, &dev_attr_bmcfw_version.attr, + &dev_attr_mac_address.attr, + &dev_attr_mac_count.attr,NULL , };ATTRIBUTE_GROUPS (m10bmc);include/linux/mfd/intel-m10-bmc.h +9
-0@@ -15,6 +15,15 @@/* Register offset of system registers */ #define NIOS2_FW_VERSION 0x0 +#define M10BMC_MACADDR1 0x10 +#define M10BMC_MAC_BYTE4 GENMASK(7, 0) +#define M10BMC_MAC_BYTE3 GENMASK(15, 8) +#define M10BMC_MAC_BYTE2 GENMASK(23, 16) +#define M10BMC_MAC_BYTE1 GENMASK(31, 24) +#define M10BMC_MACADDR2 0x14 +#define M10BMC_MAC_BYTE6 GENMASK(7, 0) +#define M10BMC_MAC_BYTE5 GENMASK(15, 8) +#define M10BMC_MAC_COUNT GENMASK(23, 16)#define M10BMC_TEST_REG 0x3c#define M10BMC_BUILD_VER 0x68#define M10BMC_VER_MAJOR_MSK GENMASK(23, 16)