Loading drivers/net/ethernet/huawei/hinic/Makefile +2 −2 Original line number Diff line number Diff line obj-$(CONFIG_HINIC) += hinic.o hinic-y := hinic_main.o hinic_tx.o hinic_rx.o hinic_port.o hinic_hw_dev.o \ hinic_hw_io.o hinic_hw_mgmt.o hinic_hw_api_cmd.o hinic_hw_eqs.o \ hinic_hw_if.o hinic_hw_io.o hinic_hw_wq.o hinic_hw_mgmt.o hinic_hw_api_cmd.o \ hinic_hw_eqs.o hinic_hw_if.o drivers/net/ethernet/huawei/hinic/hinic_common.h 0 → 100644 +25 −0 Original line number Diff line number Diff line /* * Huawei HiNIC PCI Express Linux driver * Copyright(c) 2017 Huawei Technologies Co., Ltd * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. * */ #ifndef HINIC_COMMON_H #define HINIC_COMMON_H struct hinic_sge { u32 hi_addr; u32 lo_addr; u32 len; }; #endif drivers/net/ethernet/huawei/hinic/hinic_hw_io.c +66 −3 Original line number Diff line number Diff line Loading @@ -20,6 +20,8 @@ #include <linux/slab.h> #include "hinic_hw_if.h" #include "hinic_hw_wqe.h" #include "hinic_hw_wq.h" #include "hinic_hw_qp.h" #include "hinic_hw_io.h" Loading @@ -38,8 +40,33 @@ static int init_qp(struct hinic_func_to_io *func_to_io, struct msix_entry *sq_msix_entry, struct msix_entry *rq_msix_entry) { /* should be implemented */ struct hinic_hwif *hwif = func_to_io->hwif; struct pci_dev *pdev = hwif->pdev; int err; qp->q_id = q_id; err = hinic_wq_allocate(&func_to_io->wqs, &func_to_io->sq_wq[q_id], HINIC_SQ_WQEBB_SIZE, HINIC_SQ_PAGE_SIZE, HINIC_SQ_DEPTH, HINIC_SQ_WQE_MAX_SIZE); if (err) { dev_err(&pdev->dev, "Failed to allocate WQ for SQ\n"); return err; } err = hinic_wq_allocate(&func_to_io->wqs, &func_to_io->rq_wq[q_id], HINIC_RQ_WQEBB_SIZE, HINIC_RQ_PAGE_SIZE, HINIC_RQ_DEPTH, HINIC_RQ_WQE_SIZE); if (err) { dev_err(&pdev->dev, "Failed to allocate WQ for RQ\n"); goto err_rq_alloc; } return 0; err_rq_alloc: hinic_wq_free(&func_to_io->wqs, &func_to_io->sq_wq[q_id]); return err; } /** Loading @@ -50,7 +77,10 @@ static int init_qp(struct hinic_func_to_io *func_to_io, static void destroy_qp(struct hinic_func_to_io *func_to_io, struct hinic_qp *qp) { /* should be implemented */ int q_id = qp->q_id; hinic_wq_free(&func_to_io->wqs, &func_to_io->rq_wq[q_id]); hinic_wq_free(&func_to_io->wqs, &func_to_io->sq_wq[q_id]); } /** Loading @@ -70,7 +100,7 @@ int hinic_io_create_qps(struct hinic_func_to_io *func_to_io, { struct hinic_hwif *hwif = func_to_io->hwif; struct pci_dev *pdev = hwif->pdev; size_t qps_size; size_t qps_size, wq_size; int i, j, err; qps_size = num_qps * sizeof(*func_to_io->qps); Loading @@ -78,6 +108,20 @@ int hinic_io_create_qps(struct hinic_func_to_io *func_to_io, if (!func_to_io->qps) return -ENOMEM; wq_size = num_qps * sizeof(*func_to_io->sq_wq); func_to_io->sq_wq = devm_kzalloc(&pdev->dev, wq_size, GFP_KERNEL); if (!func_to_io->sq_wq) { err = -ENOMEM; goto err_sq_wq; } wq_size = num_qps * sizeof(*func_to_io->rq_wq); func_to_io->rq_wq = devm_kzalloc(&pdev->dev, wq_size, GFP_KERNEL); if (!func_to_io->rq_wq) { err = -ENOMEM; goto err_rq_wq; } for (i = 0; i < num_qps; i++) { err = init_qp(func_to_io, &func_to_io->qps[i], i, &sq_msix_entries[i], &rq_msix_entries[i]); Loading @@ -93,6 +137,12 @@ int hinic_io_create_qps(struct hinic_func_to_io *func_to_io, for (j = 0; j < i; j++) destroy_qp(func_to_io, &func_to_io->qps[j]); devm_kfree(&pdev->dev, func_to_io->rq_wq); err_rq_wq: devm_kfree(&pdev->dev, func_to_io->sq_wq); err_sq_wq: devm_kfree(&pdev->dev, func_to_io->qps); return err; } Loading @@ -111,6 +161,9 @@ void hinic_io_destroy_qps(struct hinic_func_to_io *func_to_io, int num_qps) for (i = 0; i < num_qps; i++) destroy_qp(func_to_io, &func_to_io->qps[i]); devm_kfree(&pdev->dev, func_to_io->rq_wq); devm_kfree(&pdev->dev, func_to_io->sq_wq); devm_kfree(&pdev->dev, func_to_io->qps); } Loading @@ -128,10 +181,19 @@ int hinic_io_init(struct hinic_func_to_io *func_to_io, struct hinic_hwif *hwif, u16 max_qps, int num_ceqs, struct msix_entry *ceq_msix_entries) { struct pci_dev *pdev = hwif->pdev; int err; func_to_io->hwif = hwif; func_to_io->qps = NULL; func_to_io->max_qps = max_qps; err = hinic_wqs_alloc(&func_to_io->wqs, 2 * max_qps, hwif); if (err) { dev_err(&pdev->dev, "Failed to allocate WQS for IO\n"); return err; } return 0; } Loading @@ -141,4 +203,5 @@ int hinic_io_init(struct hinic_func_to_io *func_to_io, **/ void hinic_io_free(struct hinic_func_to_io *func_to_io) { hinic_wqs_free(&func_to_io->wqs); } drivers/net/ethernet/huawei/hinic/hinic_hw_io.h +6 −0 Original line number Diff line number Diff line Loading @@ -20,11 +20,17 @@ #include <linux/pci.h> #include "hinic_hw_if.h" #include "hinic_hw_wq.h" #include "hinic_hw_qp.h" struct hinic_func_to_io { struct hinic_hwif *hwif; struct hinic_wqs wqs; struct hinic_wq *sq_wq; struct hinic_wq *rq_wq; struct hinic_qp *qps; u16 max_qps; }; Loading drivers/net/ethernet/huawei/hinic/hinic_hw_qp.h +14 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,18 @@ #ifndef HINIC_HW_QP_H #define HINIC_HW_QP_H #include <linux/types.h> #include <linux/sizes.h> #define HINIC_SQ_WQEBB_SIZE 64 #define HINIC_RQ_WQEBB_SIZE 32 #define HINIC_SQ_PAGE_SIZE SZ_4K #define HINIC_RQ_PAGE_SIZE SZ_4K #define HINIC_SQ_DEPTH SZ_4K #define HINIC_RQ_DEPTH SZ_4K struct hinic_sq { /* should be implemented */ }; Loading @@ -27,6 +39,8 @@ struct hinic_rq { struct hinic_qp { struct hinic_sq sq; struct hinic_rq rq; u16 q_id; }; #endif Loading
drivers/net/ethernet/huawei/hinic/Makefile +2 −2 Original line number Diff line number Diff line obj-$(CONFIG_HINIC) += hinic.o hinic-y := hinic_main.o hinic_tx.o hinic_rx.o hinic_port.o hinic_hw_dev.o \ hinic_hw_io.o hinic_hw_mgmt.o hinic_hw_api_cmd.o hinic_hw_eqs.o \ hinic_hw_if.o hinic_hw_io.o hinic_hw_wq.o hinic_hw_mgmt.o hinic_hw_api_cmd.o \ hinic_hw_eqs.o hinic_hw_if.o
drivers/net/ethernet/huawei/hinic/hinic_common.h 0 → 100644 +25 −0 Original line number Diff line number Diff line /* * Huawei HiNIC PCI Express Linux driver * Copyright(c) 2017 Huawei Technologies Co., Ltd * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. * */ #ifndef HINIC_COMMON_H #define HINIC_COMMON_H struct hinic_sge { u32 hi_addr; u32 lo_addr; u32 len; }; #endif
drivers/net/ethernet/huawei/hinic/hinic_hw_io.c +66 −3 Original line number Diff line number Diff line Loading @@ -20,6 +20,8 @@ #include <linux/slab.h> #include "hinic_hw_if.h" #include "hinic_hw_wqe.h" #include "hinic_hw_wq.h" #include "hinic_hw_qp.h" #include "hinic_hw_io.h" Loading @@ -38,8 +40,33 @@ static int init_qp(struct hinic_func_to_io *func_to_io, struct msix_entry *sq_msix_entry, struct msix_entry *rq_msix_entry) { /* should be implemented */ struct hinic_hwif *hwif = func_to_io->hwif; struct pci_dev *pdev = hwif->pdev; int err; qp->q_id = q_id; err = hinic_wq_allocate(&func_to_io->wqs, &func_to_io->sq_wq[q_id], HINIC_SQ_WQEBB_SIZE, HINIC_SQ_PAGE_SIZE, HINIC_SQ_DEPTH, HINIC_SQ_WQE_MAX_SIZE); if (err) { dev_err(&pdev->dev, "Failed to allocate WQ for SQ\n"); return err; } err = hinic_wq_allocate(&func_to_io->wqs, &func_to_io->rq_wq[q_id], HINIC_RQ_WQEBB_SIZE, HINIC_RQ_PAGE_SIZE, HINIC_RQ_DEPTH, HINIC_RQ_WQE_SIZE); if (err) { dev_err(&pdev->dev, "Failed to allocate WQ for RQ\n"); goto err_rq_alloc; } return 0; err_rq_alloc: hinic_wq_free(&func_to_io->wqs, &func_to_io->sq_wq[q_id]); return err; } /** Loading @@ -50,7 +77,10 @@ static int init_qp(struct hinic_func_to_io *func_to_io, static void destroy_qp(struct hinic_func_to_io *func_to_io, struct hinic_qp *qp) { /* should be implemented */ int q_id = qp->q_id; hinic_wq_free(&func_to_io->wqs, &func_to_io->rq_wq[q_id]); hinic_wq_free(&func_to_io->wqs, &func_to_io->sq_wq[q_id]); } /** Loading @@ -70,7 +100,7 @@ int hinic_io_create_qps(struct hinic_func_to_io *func_to_io, { struct hinic_hwif *hwif = func_to_io->hwif; struct pci_dev *pdev = hwif->pdev; size_t qps_size; size_t qps_size, wq_size; int i, j, err; qps_size = num_qps * sizeof(*func_to_io->qps); Loading @@ -78,6 +108,20 @@ int hinic_io_create_qps(struct hinic_func_to_io *func_to_io, if (!func_to_io->qps) return -ENOMEM; wq_size = num_qps * sizeof(*func_to_io->sq_wq); func_to_io->sq_wq = devm_kzalloc(&pdev->dev, wq_size, GFP_KERNEL); if (!func_to_io->sq_wq) { err = -ENOMEM; goto err_sq_wq; } wq_size = num_qps * sizeof(*func_to_io->rq_wq); func_to_io->rq_wq = devm_kzalloc(&pdev->dev, wq_size, GFP_KERNEL); if (!func_to_io->rq_wq) { err = -ENOMEM; goto err_rq_wq; } for (i = 0; i < num_qps; i++) { err = init_qp(func_to_io, &func_to_io->qps[i], i, &sq_msix_entries[i], &rq_msix_entries[i]); Loading @@ -93,6 +137,12 @@ int hinic_io_create_qps(struct hinic_func_to_io *func_to_io, for (j = 0; j < i; j++) destroy_qp(func_to_io, &func_to_io->qps[j]); devm_kfree(&pdev->dev, func_to_io->rq_wq); err_rq_wq: devm_kfree(&pdev->dev, func_to_io->sq_wq); err_sq_wq: devm_kfree(&pdev->dev, func_to_io->qps); return err; } Loading @@ -111,6 +161,9 @@ void hinic_io_destroy_qps(struct hinic_func_to_io *func_to_io, int num_qps) for (i = 0; i < num_qps; i++) destroy_qp(func_to_io, &func_to_io->qps[i]); devm_kfree(&pdev->dev, func_to_io->rq_wq); devm_kfree(&pdev->dev, func_to_io->sq_wq); devm_kfree(&pdev->dev, func_to_io->qps); } Loading @@ -128,10 +181,19 @@ int hinic_io_init(struct hinic_func_to_io *func_to_io, struct hinic_hwif *hwif, u16 max_qps, int num_ceqs, struct msix_entry *ceq_msix_entries) { struct pci_dev *pdev = hwif->pdev; int err; func_to_io->hwif = hwif; func_to_io->qps = NULL; func_to_io->max_qps = max_qps; err = hinic_wqs_alloc(&func_to_io->wqs, 2 * max_qps, hwif); if (err) { dev_err(&pdev->dev, "Failed to allocate WQS for IO\n"); return err; } return 0; } Loading @@ -141,4 +203,5 @@ int hinic_io_init(struct hinic_func_to_io *func_to_io, **/ void hinic_io_free(struct hinic_func_to_io *func_to_io) { hinic_wqs_free(&func_to_io->wqs); }
drivers/net/ethernet/huawei/hinic/hinic_hw_io.h +6 −0 Original line number Diff line number Diff line Loading @@ -20,11 +20,17 @@ #include <linux/pci.h> #include "hinic_hw_if.h" #include "hinic_hw_wq.h" #include "hinic_hw_qp.h" struct hinic_func_to_io { struct hinic_hwif *hwif; struct hinic_wqs wqs; struct hinic_wq *sq_wq; struct hinic_wq *rq_wq; struct hinic_qp *qps; u16 max_qps; }; Loading
drivers/net/ethernet/huawei/hinic/hinic_hw_qp.h +14 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,18 @@ #ifndef HINIC_HW_QP_H #define HINIC_HW_QP_H #include <linux/types.h> #include <linux/sizes.h> #define HINIC_SQ_WQEBB_SIZE 64 #define HINIC_RQ_WQEBB_SIZE 32 #define HINIC_SQ_PAGE_SIZE SZ_4K #define HINIC_RQ_PAGE_SIZE SZ_4K #define HINIC_SQ_DEPTH SZ_4K #define HINIC_RQ_DEPTH SZ_4K struct hinic_sq { /* should be implemented */ }; Loading @@ -27,6 +39,8 @@ struct hinic_rq { struct hinic_qp { struct hinic_sq sq; struct hinic_rq rq; u16 q_id; }; #endif