X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=drivers%2Fraw%2Fifpga_rawdev%2Fbase%2Fifpga_feature_dev.h;h=e243d4273930f0296188f4bc10e462836183ea9a;hb=e66a5a827064f27258e54f3065fcf515936b7513;hp=cd114fbeb9b921f29ae75889ca00f1c9bd395498;hpb=56bb54ea1bdf186f81ece23aa59b1e07e43eaa6e;p=dpdk.git diff --git a/drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.h b/drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.h index cd114fbeb9..e243d42739 100644 --- a/drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.h +++ b/drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.h @@ -7,6 +7,18 @@ #include "ifpga_hw.h" +struct feature_driver { + u64 id; + const char *name; + struct ifpga_feature_ops *ops; +}; + +/** + * FEATURE_DRV - macro used to describe a specific feature driver + */ +#define FEATURE_DRV(n, s, p) \ + .id = (n), .name = (s), .ops = (p) + static inline struct ifpga_port_hw * get_port(struct ifpga_hw *hw, u32 port_id) { @@ -16,16 +28,18 @@ get_port(struct ifpga_hw *hw, u32 port_id) return &hw->port[port_id]; } -#define ifpga_for_each_feature(hw, feature) \ - for ((feature) = (hw)->sub_feature; \ - (feature) < (hw)->sub_feature + (FME_FEATURE_ID_MAX); (feature)++) +#define ifpga_for_each_fme_feature(hw, feature) \ + TAILQ_FOREACH(feature, &hw->feature_list, next) -static inline struct feature * +#define ifpga_for_each_port_feature(port, feature) \ + TAILQ_FOREACH(feature, &port->feature_list, next) + +static inline struct ifpga_feature * get_fme_feature_by_id(struct ifpga_fme_hw *fme, u64 id) { - struct feature *feature; + struct ifpga_feature *feature; - ifpga_for_each_feature(fme, feature) { + ifpga_for_each_fme_feature(fme, feature) { if (feature->id == id) return feature; } @@ -33,12 +47,12 @@ get_fme_feature_by_id(struct ifpga_fme_hw *fme, u64 id) return NULL; } -static inline struct feature * +static inline struct ifpga_feature * get_port_feature_by_id(struct ifpga_port_hw *port, u64 id) { - struct feature *feature; + struct ifpga_feature *feature; - ifpga_for_each_feature(port, feature) { + ifpga_for_each_port_feature(port, feature) { if (feature->id == id) return feature; } @@ -46,16 +60,34 @@ get_port_feature_by_id(struct ifpga_port_hw *port, u64 id) return NULL; } +static inline struct ifpga_feature * +get_feature_by_id(struct ifpga_feature_list *list, u64 id) +{ + struct ifpga_feature *feature; + + TAILQ_FOREACH(feature, list, next) + if (feature->id == id) + return feature; + + return NULL; +} + static inline void * get_fme_feature_ioaddr_by_index(struct ifpga_fme_hw *fme, int index) { - return fme->sub_feature[index].addr; + struct ifpga_feature *feature = + get_feature_by_id(&fme->feature_list, index); + + return feature ? feature->addr : NULL; } static inline void * get_port_feature_ioaddr_by_index(struct ifpga_port_hw *port, int index) { - return port->sub_feature[index].addr; + struct ifpga_feature *feature = + get_feature_by_id(&port->feature_list, index); + + return feature ? feature->addr : NULL; } static inline bool @@ -117,7 +149,7 @@ static inline int fpga_port_reset(struct ifpga_port_hw *port) return ret; } -int do_pr(struct ifpga_hw *hw, u32 port_id, void *buffer, u32 size, +int do_pr(struct ifpga_hw *hw, u32 port_id, const char *buffer, u32 size, u64 *status); int fme_get_prop(struct ifpga_fme_hw *fme, struct feature_prop *prop); @@ -132,13 +164,19 @@ int port_clear_error(struct ifpga_port_hw *port); void port_err_mask(struct ifpga_port_hw *port, bool mask); int port_err_clear(struct ifpga_port_hw *port, u64 err); -extern struct feature_ops fme_hdr_ops; -extern struct feature_ops fme_thermal_mgmt_ops; -extern struct feature_ops fme_power_mgmt_ops; -extern struct feature_ops fme_global_err_ops; -extern struct feature_ops fme_pr_mgmt_ops; -extern struct feature_ops fme_global_iperf_ops; -extern struct feature_ops fme_global_dperf_ops; +extern struct ifpga_feature_ops fme_hdr_ops; +extern struct ifpga_feature_ops fme_thermal_mgmt_ops; +extern struct ifpga_feature_ops fme_power_mgmt_ops; +extern struct ifpga_feature_ops fme_global_err_ops; +extern struct ifpga_feature_ops fme_pr_mgmt_ops; +extern struct ifpga_feature_ops fme_global_iperf_ops; +extern struct ifpga_feature_ops fme_global_dperf_ops; +extern struct ifpga_feature_ops fme_hssi_eth_ops; +extern struct ifpga_feature_ops fme_emif_ops; +extern struct ifpga_feature_ops fme_spi_master_ops; +extern struct ifpga_feature_ops fme_i2c_master_ops; +extern struct ifpga_feature_ops fme_eth_group_ops; +extern struct ifpga_feature_ops fme_nios_spi_master_ops; int port_get_prop(struct ifpga_port_hw *port, struct feature_prop *prop); int port_set_prop(struct ifpga_port_hw *port, struct feature_prop *prop); @@ -151,14 +189,33 @@ struct fpga_uafu_irq_set { }; int port_set_irq(struct ifpga_port_hw *port, u32 feature_id, void *irq_set); +const char *get_fme_feature_name(unsigned int id); +const char *get_port_feature_name(unsigned int id); -extern struct feature_ops port_hdr_ops; -extern struct feature_ops port_error_ops; -extern struct feature_ops port_stp_ops; -extern struct feature_ops port_uint_ops; +extern struct ifpga_feature_ops ifpga_rawdev_port_hdr_ops; +extern struct ifpga_feature_ops ifpga_rawdev_port_error_ops; +extern struct ifpga_feature_ops ifpga_rawdev_port_stp_ops; +extern struct ifpga_feature_ops ifpga_rawdev_port_uint_ops; +extern struct ifpga_feature_ops ifpga_rawdev_port_afu_ops; /* help functions for feature ops */ -int fpga_msix_set_block(struct feature *feature, unsigned int start, +int fpga_msix_set_block(struct ifpga_feature *feature, unsigned int start, unsigned int count, s32 *fds); +/* FME network function ops*/ +int fme_mgr_read_mac_rom(struct ifpga_fme_hw *fme, int offset, + void *buf, int size); +int fme_mgr_write_mac_rom(struct ifpga_fme_hw *fme, int offset, + void *buf, int size); +int fme_mgr_get_eth_group_nums(struct ifpga_fme_hw *fme); +int fme_mgr_get_eth_group_info(struct ifpga_fme_hw *fme, + u8 group_id, struct opae_eth_group_info *info); +int fme_mgr_eth_group_read_reg(struct ifpga_fme_hw *fme, u8 group_id, + u8 type, u8 index, u16 addr, u32 *data); +int fme_mgr_eth_group_write_reg(struct ifpga_fme_hw *fme, u8 group_id, + u8 type, u8 index, u16 addr, u32 data); +int fme_mgr_get_retimer_info(struct ifpga_fme_hw *fme, + struct opae_retimer_info *info); +int fme_mgr_get_retimer_status(struct ifpga_fme_hw *fme, + struct opae_retimer_status *status); #endif /* _IFPGA_FEATURE_DEV_H_ */