Skip to contentSkip to conversation

net/mana: add support to update MTU

PATCH Applied [email protected] 2 participants 4 messages Jul 25, 2023 – Sep 28, 2023 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/mana: add support to update MTU

From: Long Li <[email protected]>

Add support for updating MTU for MANA. MTU is updated in kernel through socket interface.

---
 doc/guides/nics/features/mana.ini |  1 +
 drivers/net/mana/mana.c           | 96 ++++++++++++++++++++++++++++++-
 drivers/net/mana/mana.h           |  2 +-
 3 files changed, 96 insertions(+), 3 deletions(-)
doc/guides/nics/features/mana.ini +1 -0
index e69bf4af15..42fd3327d2 100644
@@ -13,6 +13,7 @@ RSS hash             = Y
 L3 checksum offload  = Y
 L4 checksum offload  = Y
 Basic stats          = Y
+MTU update           = Y
 Multiprocess aware   = Y
 Linux                = Y
 x86-64               = Y
drivers/net/mana/mana.c +94 -2

123 lines not on this page · raw message

drivers/net/mana/mana.h +1 -1
index 5801491d75..ee8ea4aee3 100644
@@ -16,8 +16,8 @@ struct mana_shared_data {
 	unsigned int secondary_cnt;
 };
 
+#define MANA_MAX_MTU	9000
 #define MIN_RX_BUF_SIZE	1024
-#define MAX_FRAME_SIZE	RTE_ETHER_MAX_LEN
 #define MANA_MAX_MAC_ADDR 1
 
 #define MANA_DEV_RX_OFFLOAD_SUPPORT ( \
Signature · 1 line
2.34.1
#1 lore raw

PATCH 1/1 net/mana: use %m for fscanf to read mac address

From: Long Li <[email protected]>

Use %m through fscanf to allocate mac dynamically is safer than using mac[20], this guarantees there is no overflow on mac[].

---
 drivers/net/mana/mana.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/mana/mana.c +4 -2
index f1fdcf426a..28d8f5b23e 100644
@@ -914,7 +914,6 @@ get_port_mac(struct ibv_device *device, unsigned int port,
 	DIR *dir;
 	struct dirent *dent;
 	unsigned int dev_port;
-	char mac[20];
 
 	MANA_MKSTR(path, "%s/device/net", device->ibdev_path);
 
@@ -924,6 +923,7 @@ get_port_mac(struct ibv_device *device, unsigned int port,
 
 	while ((dent = readdir(dir))) {
 		char *name = dent->d_name;
+		char *mac = NULL;
 
 		MANA_MKSTR(port_path, "%s/%s/dev_port", path, name);
 
@@ -951,7 +951,7 @@ get_port_mac(struct ibv_device *device, unsigned int port,
 			if (!file)
 				continue;
 
-			ret = fscanf(file, "%s", mac);
+			ret = fscanf(file, "%ms", &mac);
 			fclose(file);
 
 			if (ret < 0)
@@ -960,6 +960,8 @@ get_port_mac(struct ibv_device *device, unsigned int port,
 			ret = rte_ether_unformat_addr(mac, addr);
 			if (ret)
 				DRV_LOG(ERR, "unrecognized mac addr %s", mac);
+
+			free(mac);
 			break;
 		}
 	}
Signature · 1 line
2.34.1