Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause 2 : : * Copyright (c) 2015-2018 Atomic Rules LLC 3 : : */ 4 : : 5 : : #include <stdint.h> 6 : : #include <inttypes.h> 7 : : 8 : : #include "ark_pktdir.h" 9 : : #include "ark_global.h" 10 : : #include "ark_logs.h" 11 : : 12 : : 13 : : ark_pkt_dir_t 14 : 0 : ark_pktdir_init(void *base) 15 : : { 16 : : struct ark_pkt_dir_inst *inst = 17 : 0 : rte_malloc("ark_pkt_dir_inst", 18 : : sizeof(struct ark_pkt_dir_inst), 19 : : 0); 20 [ # # ]: 0 : if (inst == NULL) { 21 : 0 : ARK_PMD_LOG(ERR, "Failed to malloc ark_pkt_dir_inst.\n"); 22 : 0 : return inst; 23 : : } 24 : 0 : inst->regs = (struct ark_pkt_dir_regs *)base; 25 : 0 : inst->regs->ctrl = ARK_PKT_DIR_INIT_VAL; /* POR state */ 26 : 0 : return inst; 27 : : } 28 : : 29 : : void 30 : 0 : ark_pktdir_uninit(ark_pkt_dir_t handle) 31 : : { 32 : : struct ark_pkt_dir_inst *inst = (struct ark_pkt_dir_inst *)handle; 33 : : 34 : 0 : rte_free(inst); 35 : 0 : } 36 : : 37 : : void 38 : 0 : ark_pktdir_setup(ark_pkt_dir_t handle, uint32_t v) 39 : : { 40 : : struct ark_pkt_dir_inst *inst = (struct ark_pkt_dir_inst *)handle; 41 : 0 : inst->regs->ctrl = v; 42 : 0 : } 43 : : 44 : : uint32_t 45 : 0 : ark_pktdir_status(ark_pkt_dir_t handle) 46 : : { 47 : : struct ark_pkt_dir_inst *inst = (struct ark_pkt_dir_inst *)handle; 48 : 0 : return inst->regs->ctrl; 49 : : } 50 : : 51 : : uint32_t 52 : 0 : ark_pktdir_stall_cnt(ark_pkt_dir_t handle) 53 : : { 54 : : struct ark_pkt_dir_inst *inst = (struct ark_pkt_dir_inst *)handle; 55 : 0 : return inst->regs->stall_cnt; 56 : : }