aboutsummaryrefslogtreecommitdiff
path: root/drivers/net/ethernet/huawei/hinic/hinic_port.c
diff options
context:
space:
mode:
authorGravatar Xue Chaojing <xuechaojing@huawei.com> 2018-11-20 05:47:32 +0000
committerGravatar David S. Miller <davem@davemloft.net> 2018-11-20 10:38:08 -0800
commit4a61abb100c8a647959147034f60e9fce17ce9af (patch)
tree22cb4e021ce58dc605f0fef411f961a69cf55bef /drivers/net/ethernet/huawei/hinic/hinic_port.c
parentnet-next/hinic:replace multiply and division operators (diff)
downloadlinux-4a61abb100c8a647959147034f60e9fce17ce9af.tar.gz
linux-4a61abb100c8a647959147034f60e9fce17ce9af.tar.bz2
linux-4a61abb100c8a647959147034f60e9fce17ce9af.zip
net-next/hinic:add rx checksum offload for HiNIC
In order to improve performance, this patch adds rx checksum offload for the HiNIC driver. Performance test(Iperf) shows more than 80% improvement in TCP streams. Signed-off-by: Xue Chaojing <xuechaojing@huawei.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/huawei/hinic/hinic_port.c')
-rw-r--r--drivers/net/ethernet/huawei/hinic/hinic_port.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/drivers/net/ethernet/huawei/hinic/hinic_port.c b/drivers/net/ethernet/huawei/hinic/hinic_port.c
index 7575a7d3bd9f..e9f76e904610 100644
--- a/drivers/net/ethernet/huawei/hinic/hinic_port.c
+++ b/drivers/net/ethernet/huawei/hinic/hinic_port.c
@@ -409,3 +409,31 @@ int hinic_port_set_tso(struct hinic_dev *nic_dev, enum hinic_tso_state state)
return 0;
}
+
+int hinic_set_rx_csum_offload(struct hinic_dev *nic_dev, u32 en)
+{
+ struct hinic_checksum_offload rx_csum_cfg = {0};
+ struct hinic_hwdev *hwdev = nic_dev->hwdev;
+ struct hinic_hwif *hwif = hwdev->hwif;
+ struct pci_dev *pdev = hwif->pdev;
+ u16 out_size;
+ int err;
+
+ if (!hwdev)
+ return -EINVAL;
+
+ rx_csum_cfg.func_id = HINIC_HWIF_FUNC_IDX(hwif);
+ rx_csum_cfg.rx_csum_offload = en;
+
+ err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_SET_RX_CSUM,
+ &rx_csum_cfg, sizeof(rx_csum_cfg),
+ &rx_csum_cfg, &out_size);
+ if (err || !out_size || rx_csum_cfg.status) {
+ dev_err(&pdev->dev,
+ "Failed to set rx csum offload, ret = %d\n",
+ rx_csum_cfg.status);
+ return -EINVAL;
+ }
+
+ return 0;
+}