#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/errno.h>
#include <linux/pci.h>
#include <linux/dma-mapping.h>
#include <linux/slab.h>
#include <linux/io-mapping.h>
#include <linux/delay.h>
#include <linux/etherdevice.h>
#include <net/devlink.h>
#include <uapi/rdma/mlx4-abi.h>
#include <linux/mlx4/device.h>
#include <linux/mlx4/doorbell.h>
#include "mlx4.h"
#include "fw.h"
#include "icm.h"
MODULE_AUTHOR(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_LICENSE(…) …;
MODULE_VERSION(…);
struct workqueue_struct *mlx4_wq;
#ifdef CONFIG_MLX4_DEBUG
int mlx4_debug_level;
module_param_named(debug_level, mlx4_debug_level, int, 0644);
MODULE_PARM_DESC(…) …;
#endif
#ifdef CONFIG_PCI_MSI
static int msi_x = …;
module_param(msi_x, int, 0444);
MODULE_PARM_DESC(…) …;
#else
#define msi_x …
#endif
static uint8_t num_vfs[3] = …;
static int num_vfs_argc;
module_param_array(…);
MODULE_PARM_DESC(…) …;
static uint8_t probe_vf[3] = …;
static int probe_vfs_argc;
module_param_array(…);
MODULE_PARM_DESC(…) …;
static int mlx4_log_num_mgm_entry_size = …;
module_param_named(log_num_mgm_entry_size,
mlx4_log_num_mgm_entry_size, int, 0444);
MODULE_PARM_DESC(…) …;
static bool enable_64b_cqe_eqe = …;
module_param(enable_64b_cqe_eqe, bool, 0444);
MODULE_PARM_DESC(…) …;
static bool enable_4k_uar;
module_param(enable_4k_uar, bool, 0444);
MODULE_PARM_DESC(…) …;
#define PF_CONTEXT_BEHAVIOUR_MASK …
#define RESET_PERSIST_MASK_FLAGS …
static char mlx4_version[] = …;
static const struct mlx4_profile default_profile = …;
static const struct mlx4_profile low_mem_profile = …;
static int log_num_mac = …;
module_param_named(log_num_mac, log_num_mac, int, 0444);
MODULE_PARM_DESC(…) …;
static int log_num_vlan;
module_param_named(log_num_vlan, log_num_vlan, int, 0444);
MODULE_PARM_DESC(…) …;
#define MLX4_LOG_NUM_VLANS …
#define MLX4_MIN_LOG_NUM_VLANS …
#define MLX4_MIN_LOG_NUM_MAC …
static bool use_prio;
module_param_named(use_prio, use_prio, bool, 0444);
MODULE_PARM_DESC(…) …;
int log_mtts_per_seg = …;
module_param_named(log_mtts_per_seg, log_mtts_per_seg, int, 0444);
MODULE_PARM_DESC(…) …;
static int port_type_array[2] = …;
static int arr_argc = …;
module_param_array(…);
MODULE_PARM_DESC(…) …;
static atomic_t pf_loading = …;
static int mlx4_devlink_ierr_reset_get(struct devlink *devlink, u32 id,
struct devlink_param_gset_ctx *ctx)
{ … }
static int mlx4_devlink_ierr_reset_set(struct devlink *devlink, u32 id,
struct devlink_param_gset_ctx *ctx,
struct netlink_ext_ack *extack)
{ … }
static int mlx4_devlink_crdump_snapshot_get(struct devlink *devlink, u32 id,
struct devlink_param_gset_ctx *ctx)
{ … }
static int mlx4_devlink_crdump_snapshot_set(struct devlink *devlink, u32 id,
struct devlink_param_gset_ctx *ctx,
struct netlink_ext_ack *extack)
{ … }
static int
mlx4_devlink_max_macs_validate(struct devlink *devlink, u32 id,
union devlink_param_value val,
struct netlink_ext_ack *extack)
{ … }
enum mlx4_devlink_param_id { … };
static const struct devlink_param mlx4_devlink_params[] = …;
static void mlx4_devlink_set_params_init_values(struct devlink *devlink)
{ … }
static inline void mlx4_set_num_reserved_uars(struct mlx4_dev *dev,
struct mlx4_dev_cap *dev_cap)
{ … }
int mlx4_check_port_params(struct mlx4_dev *dev,
enum mlx4_port_type *port_type)
{ … }
static void mlx4_set_port_mask(struct mlx4_dev *dev)
{ … }
enum { … };
static int mlx4_query_func(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap)
{ … }
static void mlx4_enable_cqe_eqe_stride(struct mlx4_dev *dev)
{ … }
static int _mlx4_dev_port(struct mlx4_dev *dev, int port,
struct mlx4_port_cap *port_cap)
{ … }
static int mlx4_dev_port(struct mlx4_dev *dev, int port,
struct mlx4_port_cap *port_cap)
{ … }
static inline void mlx4_enable_ignore_fcs(struct mlx4_dev *dev)
{ … }
#define MLX4_A0_STEERING_TABLE_SIZE …
static int mlx4_dev_cap(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap)
{ … }
static int mlx4_how_many_lives_vf(struct mlx4_dev *dev)
{ … }
int mlx4_get_parav_qkey(struct mlx4_dev *dev, u32 qpn, u32 *qkey)
{ … }
EXPORT_SYMBOL(…);
void mlx4_sync_pkey_table(struct mlx4_dev *dev, int slave, int port, int i, int val)
{ … }
EXPORT_SYMBOL(…);
void mlx4_put_slave_node_guid(struct mlx4_dev *dev, int slave, __be64 guid)
{ … }
EXPORT_SYMBOL(…);
__be64 mlx4_get_slave_node_guid(struct mlx4_dev *dev, int slave)
{ … }
EXPORT_SYMBOL(…);
int mlx4_is_slave_active(struct mlx4_dev *dev, int slave)
{ … }
EXPORT_SYMBOL(…);
void mlx4_handle_eth_header_mcast_prio(struct mlx4_net_trans_rule_hw_ctrl *ctrl,
struct _rule_hw *eth_header)
{ … }
EXPORT_SYMBOL(…);
static void slave_adjust_steering_mode(struct mlx4_dev *dev,
struct mlx4_dev_cap *dev_cap,
struct mlx4_init_hca_param *hca_param)
{ … }
static void mlx4_slave_destroy_special_qp_cap(struct mlx4_dev *dev)
{ … }
static int mlx4_slave_special_qp_cap(struct mlx4_dev *dev)
{ … }
static int mlx4_slave_cap(struct mlx4_dev *dev)
{ … }
int mlx4_change_port_types(struct mlx4_dev *dev,
enum mlx4_port_type *port_types)
{ … }
static ssize_t show_port_type(struct device *dev,
struct device_attribute *attr,
char *buf)
{ … }
static int __set_port_type(struct mlx4_port_info *info,
enum mlx4_port_type port_type)
{ … }
static ssize_t set_port_type(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{ … }
enum ibta_mtu { … };
static inline int int_to_ibta_mtu(int mtu)
{ … }
static inline int ibta_mtu_to_int(enum ibta_mtu mtu)
{ … }
static ssize_t show_port_ib_mtu(struct device *dev,
struct device_attribute *attr,
char *buf)
{ … }
static ssize_t set_port_ib_mtu(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{ … }
#define MAX_MF_BOND_ALLOWED_SLAVES …
static int mlx4_mf_bond(struct mlx4_dev *dev)
{ … }
static int mlx4_mf_unbond(struct mlx4_dev *dev)
{ … }
static int mlx4_bond(struct mlx4_dev *dev)
{ … }
static int mlx4_unbond(struct mlx4_dev *dev)
{ … }
static int mlx4_port_map_set(struct mlx4_dev *dev, struct mlx4_port_map *v2p)
{ … }
struct mlx4_bond { … };
static void mlx4_bond_work(struct work_struct *work)
{ … }
int mlx4_queue_bond_work(struct mlx4_dev *dev, int is_bonded, u8 v2p_p1,
u8 v2p_p2)
{ … }
EXPORT_SYMBOL(…);
static int mlx4_load_fw(struct mlx4_dev *dev)
{ … }
static int mlx4_init_cmpt_table(struct mlx4_dev *dev, u64 cmpt_base,
int cmpt_entry_sz)
{ … }
static int mlx4_init_icm(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap,
struct mlx4_init_hca_param *init_hca, u64 icm_size)
{ … }
static void mlx4_free_icms(struct mlx4_dev *dev)
{ … }
static void mlx4_slave_exit(struct mlx4_dev *dev)
{ … }
static int map_bf_area(struct mlx4_dev *dev)
{ … }
static void unmap_bf_area(struct mlx4_dev *dev)
{ … }
u64 mlx4_read_clock(struct mlx4_dev *dev)
{ … }
EXPORT_SYMBOL_GPL(…);
static int map_internal_clock(struct mlx4_dev *dev)
{ … }
int mlx4_get_internal_clock_params(struct mlx4_dev *dev,
struct mlx4_clock_params *params)
{ … }
EXPORT_SYMBOL_GPL(…);
static void unmap_internal_clock(struct mlx4_dev *dev)
{ … }
static void mlx4_close_hca(struct mlx4_dev *dev)
{ … }
static void mlx4_close_fw(struct mlx4_dev *dev)
{ … }
static int mlx4_comm_check_offline(struct mlx4_dev *dev)
{ … }
static void mlx4_reset_vf_support(struct mlx4_dev *dev)
{ … }
static int mlx4_init_slave(struct mlx4_dev *dev)
{ … }
static void mlx4_parav_master_pf_caps(struct mlx4_dev *dev)
{ … }
static int choose_log_fs_mgm_entry_size(int qp_per_entry)
{ … }
static const char *dmfs_high_rate_steering_mode_str(int dmfs_high_steer_mode)
{ … }
#define MLX4_DMFS_A0_STEERING …
static void choose_steering_mode(struct mlx4_dev *dev,
struct mlx4_dev_cap *dev_cap)
{ … }
static void choose_tunnel_offload_mode(struct mlx4_dev *dev,
struct mlx4_dev_cap *dev_cap)
{ … }
static int mlx4_validate_optimized_steering(struct mlx4_dev *dev)
{ … }
static int mlx4_init_fw(struct mlx4_dev *dev)
{ … }
static int mlx4_init_hca(struct mlx4_dev *dev)
{ … }
static int mlx4_init_counters_table(struct mlx4_dev *dev)
{ … }
static void mlx4_cleanup_counters_table(struct mlx4_dev *dev)
{ … }
static void mlx4_cleanup_default_counters(struct mlx4_dev *dev)
{ … }
static int mlx4_allocate_default_counters(struct mlx4_dev *dev)
{ … }
int __mlx4_counter_alloc(struct mlx4_dev *dev, u32 *idx)
{ … }
int mlx4_counter_alloc(struct mlx4_dev *dev, u32 *idx, u8 usage)
{ … }
EXPORT_SYMBOL_GPL(…);
static int __mlx4_clear_if_stat(struct mlx4_dev *dev,
u8 counter_index)
{ … }
void __mlx4_counter_free(struct mlx4_dev *dev, u32 idx)
{ … }
void mlx4_counter_free(struct mlx4_dev *dev, u32 idx)
{ … }
EXPORT_SYMBOL_GPL(…);
int mlx4_get_default_counter_index(struct mlx4_dev *dev, int port)
{ … }
EXPORT_SYMBOL_GPL(…);
void mlx4_set_admin_guid(struct mlx4_dev *dev, __be64 guid, int entry, int port)
{ … }
EXPORT_SYMBOL_GPL(…);
__be64 mlx4_get_admin_guid(struct mlx4_dev *dev, int entry, int port)
{ … }
EXPORT_SYMBOL_GPL(…);
void mlx4_set_random_admin_guid(struct mlx4_dev *dev, int entry, int port)
{ … }
static int mlx4_setup_hca(struct mlx4_dev *dev)
{ … }
static int mlx4_init_affinity_hint(struct mlx4_dev *dev, int port, int eqn)
{ … }
static void mlx4_enable_msi_x(struct mlx4_dev *dev)
{ … }
static int mlx4_devlink_port_type_set(struct devlink_port *devlink_port,
enum devlink_port_type port_type)
{ … }
static const struct devlink_port_ops mlx4_devlink_port_ops = …;
static int mlx4_init_port_info(struct mlx4_dev *dev, int port)
{ … }
static void mlx4_cleanup_port_info(struct mlx4_port_info *info)
{ … }
static int mlx4_init_steering(struct mlx4_dev *dev)
{ … }
static void mlx4_clear_steering(struct mlx4_dev *dev)
{ … }
static int extended_func_num(struct pci_dev *pdev)
{ … }
#define MLX4_OWNER_BASE …
#define MLX4_OWNER_SIZE …
static int mlx4_get_ownership(struct mlx4_dev *dev)
{ … }
static void mlx4_free_ownership(struct mlx4_dev *dev)
{ … }
#define SRIOV_VALID_STATE(flags) …
static u64 mlx4_enable_sriov(struct mlx4_dev *dev, struct pci_dev *pdev,
u8 total_vfs, int existing_vfs, int reset_flow)
{ … }
enum { … };
static int mlx4_check_dev_cap(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap,
int *nvfs)
{ … }
static int mlx4_pci_enable_device(struct mlx4_dev *dev)
{ … }
static void mlx4_pci_disable_device(struct mlx4_dev *dev)
{ … }
static int mlx4_load_one(struct pci_dev *pdev, int pci_dev_data,
int total_vfs, int *nvfs, struct mlx4_priv *priv,
int reset_flow)
{ … }
static int __mlx4_init_one(struct pci_dev *pdev, int pci_dev_data,
struct mlx4_priv *priv)
{ … }
static void mlx4_devlink_param_load_driverinit_values(struct devlink *devlink)
{ … }
static void mlx4_restart_one_down(struct pci_dev *pdev);
static int mlx4_restart_one_up(struct pci_dev *pdev, bool reload,
struct devlink *devlink);
static int mlx4_devlink_reload_down(struct devlink *devlink, bool netns_change,
enum devlink_reload_action action,
enum devlink_reload_limit limit,
struct netlink_ext_ack *extack)
{ … }
static int mlx4_devlink_reload_up(struct devlink *devlink, enum devlink_reload_action action,
enum devlink_reload_limit limit, u32 *actions_performed,
struct netlink_ext_ack *extack)
{ … }
static const struct devlink_ops mlx4_devlink_ops = …;
static int mlx4_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
{ … }
static void mlx4_clean_dev(struct mlx4_dev *dev)
{ … }
static void mlx4_unload_one(struct pci_dev *pdev)
{ … }
static void mlx4_remove_one(struct pci_dev *pdev)
{ … }
static int restore_current_port_types(struct mlx4_dev *dev,
enum mlx4_port_type *types,
enum mlx4_port_type *poss_types)
{ … }
static void mlx4_restart_one_down(struct pci_dev *pdev)
{ … }
static int mlx4_restart_one_up(struct pci_dev *pdev, bool reload,
struct devlink *devlink)
{ … }
int mlx4_restart_one(struct pci_dev *pdev)
{ … }
#define MLX_SP(id) …
#define MLX_VF(id) …
#define MLX_GN(id) …
static const struct pci_device_id mlx4_pci_table[] = …;
MODULE_DEVICE_TABLE(pci, mlx4_pci_table);
static pci_ers_result_t mlx4_pci_err_detected(struct pci_dev *pdev,
pci_channel_state_t state)
{ … }
static pci_ers_result_t mlx4_pci_slot_reset(struct pci_dev *pdev)
{ … }
static void mlx4_pci_resume(struct pci_dev *pdev)
{ … }
static void mlx4_shutdown(struct pci_dev *pdev)
{ … }
static const struct pci_error_handlers mlx4_err_handler = …;
static int __maybe_unused mlx4_suspend(struct device *dev_d)
{ … }
static int __maybe_unused mlx4_resume(struct device *dev_d)
{ … }
static SIMPLE_DEV_PM_OPS(mlx4_pm_ops, mlx4_suspend, mlx4_resume);
static struct pci_driver mlx4_driver = …;
static int __init mlx4_verify_params(void)
{ … }
static int __init mlx4_init(void)
{ … }
static void __exit mlx4_cleanup(void)
{ … }
module_init(…) …;
module_exit(mlx4_cleanup);