Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'there-are-a-cleancode-and-a-parameter-check-for-hns3-driver'

Jijie Shao says:

====================
There are a cleancode and a parameter check for hns3 driver

This patchset includes:
1. a parameter check omitted from fix code in net branch
https://lore.kernel.org/all/20250723072900.GV2459@horms.kernel.org/
2. a small clean code
====================

Link: https://patch.msgid.link/20250815100414.949752-1-shaojijie@huawei.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

+35 -2
+33
drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
··· 1927 1927 return ret; 1928 1928 } 1929 1929 1930 + static int hns3_check_tx_copybreak(struct net_device *netdev, u32 copybreak) 1931 + { 1932 + struct hns3_nic_priv *priv = netdev_priv(netdev); 1933 + 1934 + if (copybreak < priv->min_tx_copybreak) { 1935 + netdev_err(netdev, "tx copybreak %u should be no less than %u!\n", 1936 + copybreak, priv->min_tx_copybreak); 1937 + return -EINVAL; 1938 + } 1939 + return 0; 1940 + } 1941 + 1942 + static int hns3_check_tx_spare_buf_size(struct net_device *netdev, u32 buf_size) 1943 + { 1944 + struct hns3_nic_priv *priv = netdev_priv(netdev); 1945 + 1946 + if (buf_size < priv->min_tx_spare_buf_size) { 1947 + netdev_err(netdev, 1948 + "tx spare buf size %u should be no less than %u!\n", 1949 + buf_size, priv->min_tx_spare_buf_size); 1950 + return -EINVAL; 1951 + } 1952 + return 0; 1953 + } 1954 + 1930 1955 static int hns3_set_tunable(struct net_device *netdev, 1931 1956 const struct ethtool_tunable *tuna, 1932 1957 const void *data) ··· 1968 1943 1969 1944 switch (tuna->id) { 1970 1945 case ETHTOOL_TX_COPYBREAK: 1946 + ret = hns3_check_tx_copybreak(netdev, *(u32 *)data); 1947 + if (ret) 1948 + return ret; 1949 + 1971 1950 priv->tx_copybreak = *(u32 *)data; 1972 1951 1973 1952 for (i = 0; i < h->kinfo.num_tqps; i++) ··· 1986 1957 1987 1958 break; 1988 1959 case ETHTOOL_TX_COPYBREAK_BUF_SIZE: 1960 + ret = hns3_check_tx_spare_buf_size(netdev, *(u32 *)data); 1961 + if (ret) 1962 + return ret; 1963 + 1989 1964 old_tx_spare_buf_size = h->kinfo.tx_spare_buf_size; 1990 1965 new_tx_spare_buf_size = *(u32 *)data; 1991 1966 netdev_info(netdev, "request to set tx spare buf size from %u to %u\n",
+2 -2
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
··· 2182 2182 return hclge_is_rx_buf_ok(hdev, buf_alloc, rx_all); 2183 2183 } 2184 2184 2185 - static int hclge_only_alloc_priv_buff(struct hclge_dev *hdev, 2186 - struct hclge_pkt_buf_alloc *buf_alloc) 2185 + static bool hclge_only_alloc_priv_buff(struct hclge_dev *hdev, 2186 + struct hclge_pkt_buf_alloc *buf_alloc) 2187 2187 { 2188 2188 #define COMPENSATE_BUFFER 0x3C00 2189 2189 #define COMPENSATE_HALF_MPS_NUM 5