1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright(C) 2020 Broadcom. 3 * All rights reserved. 4 */ 5 6 #ifndef _BCMFS_DEVICE_H_ 7 #define _BCMFS_DEVICE_H_ 8 9 #include <sys/queue.h> 10 11 #include <rte_spinlock.h> 12 #include <bus_vdev_driver.h> 13 14 #include "bcmfs_logs.h" 15 #include "bcmfs_qp.h" 16 17 /* max number of dev nodes */ 18 #define BCMFS_MAX_NODES 4 19 #define BCMFS_MAX_PATH_LEN 512 20 #define BCMFS_DEV_NAME_LEN 64 21 22 /* Path for BCM-Platform device directory */ 23 #define SYSFS_BCM_PLTFORM_DEVICES "/sys/bus/platform/devices" 24 25 #define BCMFS_SYM_FS4_VERSION 0x76303031 26 #define BCMFS_SYM_FS5_VERSION 0x76303032 27 28 /* Supported devices */ 29 enum bcmfs_device_type { 30 BCMFS_SYM_FS4, 31 BCMFS_SYM_FS5, 32 BCMFS_UNKNOWN 33 }; 34 35 /* A table to store registered queue pair operations */ 36 struct bcmfs_hw_queue_pair_ops_table { 37 rte_spinlock_t tl; 38 /* Number of used ops structs in the table. */ 39 uint32_t num_ops; 40 /* Storage for all possible ops structs. */ 41 struct bcmfs_hw_queue_pair_ops qp_ops[BCMFS_MAX_NODES]; 42 }; 43 44 /* HW queue pair ops register function */ 45 int 46 bcmfs_hw_queue_pair_register_ops(const struct bcmfs_hw_queue_pair_ops *qp_ops); 47 48 struct bcmfs_device { 49 TAILQ_ENTRY(bcmfs_device) next; 50 /* Directory path for vfio */ 51 char dirname[BCMFS_MAX_PATH_LEN]; 52 /* BCMFS device name */ 53 char name[BCMFS_DEV_NAME_LEN]; 54 /* Parent vdev */ 55 struct rte_vdev_device *vdev; 56 /* vfio handle */ 57 int vfio_dev_fd; 58 /* mapped address */ 59 uint8_t *mmap_addr; 60 /* mapped size */ 61 uint32_t mmap_size; 62 /* max number of h/w queue pairs detected */ 63 uint16_t max_hw_qps; 64 /* current qpairs in use */ 65 struct bcmfs_qp *qps_in_use[BCMFS_MAX_HW_QUEUES]; 66 /* queue pair ops exported by symmetric crypto hw */ 67 struct bcmfs_hw_queue_pair_ops *sym_hw_qp_ops; 68 /* a cryptodevice attached to bcmfs device */ 69 struct rte_cryptodev *cdev; 70 /* a rte_device to register with cryptodev */ 71 struct rte_device sym_rte_dev; 72 /* private info to keep with cryptodev */ 73 struct bcmfs_sym_dev_private *sym_dev; 74 }; 75 76 #endif /* _BCMFS_DEVICE_H_ */ 77