Merge "Add l3 support for tasks without physical tx ports"
[samplevnf.git] / VNFs / DPPD-PROX / rw_reg.h
1 /*
2 // Copyright (c) 2010-2017 Intel Corporation
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //     http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 */
16
17 #ifndef __RW_REG_H__
18 #define __RW_REG_H__
19
20 /* Simplified, from DPDK 1.8 */
21 struct _dev_hw {
22         uint8_t *hw_addr;
23 };
24 /* Registers access */
25
26 #define PROX_PCI_REG_ADDR(hw, reg) \
27         ((volatile uint32_t *)((char *)(hw)->hw_addr + (reg)))
28 #define PROX_READ_REG(hw, reg) \
29         prox_read_addr(PROX_PCI_REG_ADDR((hw), (reg)))
30 #define PROX_PCI_REG(reg) (*((volatile uint32_t *)(reg)))
31 #define PROX_PCI_REG_WRITE(reg_addr, value) \
32         *((volatile uint32_t *) (reg_addr)) = (value)
33 #define PROX_WRITE_REG(hw,reg,value) \
34         PROX_PCI_REG_WRITE(PROX_PCI_REG_ADDR((hw), (reg)), (value))
35
36 static inline uint32_t prox_read_addr(volatile void* addr)
37 {
38         return rte_le_to_cpu_32(PROX_PCI_REG(addr));
39 }
40
41 int read_reg(uint8_t portid, uint32_t addr, uint32_t *reg);
42 int write_reg(uint8_t portid, uint32_t reg, uint32_t val);
43 #endif