Aviad Krawczyk | c3e79ba | 2017-08-21 23:55:56 +0800 | [diff] [blame^] | 1 | /* |
| 2 | * Huawei HiNIC PCI Express Linux driver |
| 3 | * Copyright(c) 2017 Huawei Technologies Co., Ltd |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify it |
| 6 | * under the terms and conditions of the GNU General Public License, |
| 7 | * version 2, as published by the Free Software Foundation. |
| 8 | * |
| 9 | * This program is distributed in the hope it will be useful, but WITHOUT |
| 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 12 | * for more details. |
| 13 | * |
| 14 | */ |
| 15 | |
| 16 | #include <linux/netdevice.h> |
| 17 | #include <linux/u64_stats_sync.h> |
| 18 | |
| 19 | #include "hinic_hw_qp.h" |
| 20 | #include "hinic_rx.h" |
| 21 | |
| 22 | /** |
| 23 | * hinic_rxq_clean_stats - Clean the statistics of specific queue |
| 24 | * @rxq: Logical Rx Queue |
| 25 | **/ |
| 26 | void hinic_rxq_clean_stats(struct hinic_rxq *rxq) |
| 27 | { |
| 28 | struct hinic_rxq_stats *rxq_stats = &rxq->rxq_stats; |
| 29 | |
| 30 | u64_stats_update_begin(&rxq_stats->syncp); |
| 31 | rxq_stats->pkts = 0; |
| 32 | rxq_stats->bytes = 0; |
| 33 | u64_stats_update_end(&rxq_stats->syncp); |
| 34 | } |
| 35 | |
| 36 | /** |
| 37 | * rxq_stats_init - Initialize the statistics of specific queue |
| 38 | * @rxq: Logical Rx Queue |
| 39 | **/ |
| 40 | static void rxq_stats_init(struct hinic_rxq *rxq) |
| 41 | { |
| 42 | struct hinic_rxq_stats *rxq_stats = &rxq->rxq_stats; |
| 43 | |
| 44 | u64_stats_init(&rxq_stats->syncp); |
| 45 | hinic_rxq_clean_stats(rxq); |
| 46 | } |
| 47 | |
| 48 | /** |
| 49 | * hinic_init_rxq - Initialize the Rx Queue |
| 50 | * @rxq: Logical Rx Queue |
| 51 | * @rq: Hardware Rx Queue to connect the Logical queue with |
| 52 | * @netdev: network device to connect the Logical queue with |
| 53 | * |
| 54 | * Return 0 - Success, negative - Failure |
| 55 | **/ |
| 56 | int hinic_init_rxq(struct hinic_rxq *rxq, struct hinic_rq *rq, |
| 57 | struct net_device *netdev) |
| 58 | { |
| 59 | rxq->netdev = netdev; |
| 60 | rxq->rq = rq; |
| 61 | |
| 62 | rxq_stats_init(rxq); |
| 63 | return 0; |
| 64 | } |
| 65 | |
| 66 | /** |
| 67 | * hinic_clean_rxq - Clean the Rx Queue |
| 68 | * @rxq: Logical Rx Queue |
| 69 | **/ |
| 70 | void hinic_clean_rxq(struct hinic_rxq *rxq) |
| 71 | { |
| 72 | } |