2018-08-09 16:59:11 +08:00
|
|
|
/* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 */
|
|
|
|
/* Copyright (c) 2015-2018 Mellanox Technologies. All rights reserved */
|
2015-07-30 05:33:46 +08:00
|
|
|
|
|
|
|
#ifndef _MLXSW_CORE_H
|
|
|
|
#define _MLXSW_CORE_H
|
|
|
|
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/device.h>
|
|
|
|
#include <linux/slab.h>
|
|
|
|
#include <linux/gfp.h>
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/skbuff.h>
|
2016-04-15 00:19:28 +08:00
|
|
|
#include <linux/workqueue.h>
|
2019-10-03 17:49:32 +08:00
|
|
|
#include <linux/net_namespace.h>
|
2016-04-09 01:11:21 +08:00
|
|
|
#include <net/devlink.h>
|
2015-07-30 05:33:46 +08:00
|
|
|
|
2015-07-30 05:33:48 +08:00
|
|
|
#include "trap.h"
|
|
|
|
#include "reg.h"
|
2015-07-30 05:33:46 +08:00
|
|
|
#include "cmd.h"
|
2016-10-21 22:07:23 +08:00
|
|
|
#include "resources.h"
|
2015-07-30 05:33:46 +08:00
|
|
|
|
|
|
|
struct mlxsw_core;
|
2016-10-29 03:35:55 +08:00
|
|
|
struct mlxsw_core_port;
|
2015-07-30 05:33:46 +08:00
|
|
|
struct mlxsw_driver;
|
|
|
|
struct mlxsw_bus;
|
|
|
|
struct mlxsw_bus_info;
|
2019-10-06 14:34:51 +08:00
|
|
|
struct mlxsw_fw_rev;
|
2015-07-30 05:33:46 +08:00
|
|
|
|
2017-03-24 15:02:48 +08:00
|
|
|
unsigned int mlxsw_core_max_ports(const struct mlxsw_core *mlxsw_core);
|
|
|
|
|
2016-04-09 01:11:23 +08:00
|
|
|
void *mlxsw_core_driver_priv(struct mlxsw_core *mlxsw_core);
|
|
|
|
|
2019-05-18 23:58:28 +08:00
|
|
|
bool mlxsw_core_res_query_enabled(const struct mlxsw_core *mlxsw_core);
|
|
|
|
|
2019-10-06 14:34:51 +08:00
|
|
|
bool
|
|
|
|
mlxsw_core_fw_rev_minor_subminor_validate(const struct mlxsw_fw_rev *rev,
|
|
|
|
const struct mlxsw_fw_rev *req_rev);
|
|
|
|
|
2015-07-30 05:33:46 +08:00
|
|
|
int mlxsw_core_driver_register(struct mlxsw_driver *mlxsw_driver);
|
|
|
|
void mlxsw_core_driver_unregister(struct mlxsw_driver *mlxsw_driver);
|
|
|
|
|
|
|
|
int mlxsw_core_bus_device_register(const struct mlxsw_bus_info *mlxsw_bus_info,
|
|
|
|
const struct mlxsw_bus *mlxsw_bus,
|
2018-01-15 15:59:11 +08:00
|
|
|
void *bus_priv, bool reload,
|
2019-10-03 17:49:34 +08:00
|
|
|
struct devlink *devlink,
|
|
|
|
struct netlink_ext_ack *extack);
|
2018-01-15 15:59:11 +08:00
|
|
|
void mlxsw_core_bus_device_unregister(struct mlxsw_core *mlxsw_core, bool reload);
|
2015-07-30 05:33:46 +08:00
|
|
|
|
|
|
|
struct mlxsw_tx_info {
|
|
|
|
u8 local_port;
|
|
|
|
bool is_emad;
|
|
|
|
};
|
|
|
|
|
2016-04-09 01:11:22 +08:00
|
|
|
bool mlxsw_core_skb_transmit_busy(struct mlxsw_core *mlxsw_core,
|
2015-08-06 22:41:56 +08:00
|
|
|
const struct mlxsw_tx_info *tx_info);
|
2016-04-09 01:11:22 +08:00
|
|
|
int mlxsw_core_skb_transmit(struct mlxsw_core *mlxsw_core, struct sk_buff *skb,
|
2015-07-30 05:33:46 +08:00
|
|
|
const struct mlxsw_tx_info *tx_info);
|
mlxsw: pci: PTP: Hook into packet transmit path
On Spectrum-1, timestamps are delivered separately from the packets, and
need to paired up. Therefore, at some point after mlxsw_sp_port_xmit()
is invoked, it is necessary to involve the chip-specific driver code to
allow it to do the necessary bookkeeping and matching.
On Spectrum-2, timestamps are delivered in CQE. For that reason,
position the point of driver involvement into mlxsw_pci_cqe_sdq_handle()
to make it hopefully easier to extend for Spectrum-2 in the future.
To tell the driver what port the packet was sent on, keep tx_info
in SKB control buffer.
Introduce a new driver core interface mlxsw_core_ptp_transmitted(), a
driver callback ptp_transmitted, and a PTP op transmitted. The callee is
responsible for taking care of releasing the SKB passed to the new
interfaces, and correspondingly have the new stub callbacks just call
dev_kfree_skb_any().
Follow-up patches will introduce the actual content into
mlxsw_sp1_ptp_transmitted() in particular.
Signed-off-by: Petr Machata <petrm@mellanox.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2019-06-30 14:04:53 +08:00
|
|
|
void mlxsw_core_ptp_transmitted(struct mlxsw_core *mlxsw_core,
|
|
|
|
struct sk_buff *skb, u8 local_port);
|
2015-07-30 05:33:46 +08:00
|
|
|
|
|
|
|
struct mlxsw_rx_listener {
|
|
|
|
void (*func)(struct sk_buff *skb, u8 local_port, void *priv);
|
|
|
|
u8 local_port;
|
|
|
|
u16 trap_id;
|
2016-08-26 00:42:39 +08:00
|
|
|
enum mlxsw_reg_hpkt_action action;
|
2015-07-30 05:33:46 +08:00
|
|
|
};
|
|
|
|
|
2015-07-30 05:33:48 +08:00
|
|
|
struct mlxsw_event_listener {
|
|
|
|
void (*func)(const struct mlxsw_reg_info *reg,
|
|
|
|
char *payload, void *priv);
|
|
|
|
enum mlxsw_event_trap_id trap_id;
|
|
|
|
};
|
|
|
|
|
2016-11-25 17:33:30 +08:00
|
|
|
struct mlxsw_listener {
|
|
|
|
u16 trap_id;
|
|
|
|
union {
|
|
|
|
struct mlxsw_rx_listener rx_listener;
|
|
|
|
struct mlxsw_event_listener event_listener;
|
|
|
|
} u;
|
|
|
|
enum mlxsw_reg_hpkt_action action;
|
|
|
|
enum mlxsw_reg_hpkt_action unreg_action;
|
2016-11-25 17:33:38 +08:00
|
|
|
u8 trap_group;
|
|
|
|
bool is_ctrl; /* should go via control buffer or not */
|
2016-11-25 17:33:30 +08:00
|
|
|
bool is_event;
|
|
|
|
};
|
|
|
|
|
2016-11-25 17:33:39 +08:00
|
|
|
#define MLXSW_RXL(_func, _trap_id, _action, _is_ctrl, _trap_group, \
|
|
|
|
_unreg_action) \
|
2016-11-25 17:33:31 +08:00
|
|
|
{ \
|
|
|
|
.trap_id = MLXSW_TRAP_ID_##_trap_id, \
|
|
|
|
.u.rx_listener = \
|
|
|
|
{ \
|
|
|
|
.func = _func, \
|
|
|
|
.local_port = MLXSW_PORT_DONT_CARE, \
|
|
|
|
.trap_id = MLXSW_TRAP_ID_##_trap_id, \
|
|
|
|
}, \
|
|
|
|
.action = MLXSW_REG_HPKT_ACTION_##_action, \
|
|
|
|
.unreg_action = MLXSW_REG_HPKT_ACTION_##_unreg_action, \
|
2016-11-25 17:33:39 +08:00
|
|
|
.trap_group = MLXSW_REG_HTGT_TRAP_GROUP_##_trap_group, \
|
2016-11-25 17:33:38 +08:00
|
|
|
.is_ctrl = _is_ctrl, \
|
2016-11-25 17:33:31 +08:00
|
|
|
.is_event = false, \
|
|
|
|
}
|
|
|
|
|
2016-11-25 17:33:39 +08:00
|
|
|
#define MLXSW_EVENTL(_func, _trap_id, _trap_group) \
|
|
|
|
{ \
|
|
|
|
.trap_id = MLXSW_TRAP_ID_##_trap_id, \
|
|
|
|
.u.event_listener = \
|
|
|
|
{ \
|
|
|
|
.func = _func, \
|
|
|
|
.trap_id = MLXSW_TRAP_ID_##_trap_id, \
|
|
|
|
}, \
|
|
|
|
.action = MLXSW_REG_HPKT_ACTION_TRAP_TO_CPU, \
|
|
|
|
.trap_group = MLXSW_REG_HTGT_TRAP_GROUP_##_trap_group, \
|
|
|
|
.is_ctrl = false, \
|
|
|
|
.is_event = true, \
|
2016-11-25 17:33:34 +08:00
|
|
|
}
|
|
|
|
|
2015-07-30 05:33:46 +08:00
|
|
|
int mlxsw_core_rx_listener_register(struct mlxsw_core *mlxsw_core,
|
|
|
|
const struct mlxsw_rx_listener *rxl,
|
|
|
|
void *priv);
|
|
|
|
void mlxsw_core_rx_listener_unregister(struct mlxsw_core *mlxsw_core,
|
|
|
|
const struct mlxsw_rx_listener *rxl,
|
|
|
|
void *priv);
|
|
|
|
|
2015-07-30 05:33:48 +08:00
|
|
|
int mlxsw_core_event_listener_register(struct mlxsw_core *mlxsw_core,
|
|
|
|
const struct mlxsw_event_listener *el,
|
|
|
|
void *priv);
|
|
|
|
void mlxsw_core_event_listener_unregister(struct mlxsw_core *mlxsw_core,
|
|
|
|
const struct mlxsw_event_listener *el,
|
|
|
|
void *priv);
|
|
|
|
|
2016-11-25 17:33:30 +08:00
|
|
|
int mlxsw_core_trap_register(struct mlxsw_core *mlxsw_core,
|
|
|
|
const struct mlxsw_listener *listener,
|
|
|
|
void *priv);
|
|
|
|
void mlxsw_core_trap_unregister(struct mlxsw_core *mlxsw_core,
|
|
|
|
const struct mlxsw_listener *listener,
|
|
|
|
void *priv);
|
2019-08-21 15:19:31 +08:00
|
|
|
int mlxsw_core_trap_action_set(struct mlxsw_core *mlxsw_core,
|
|
|
|
const struct mlxsw_listener *listener,
|
|
|
|
enum mlxsw_reg_hpkt_action action);
|
2016-11-25 17:33:30 +08:00
|
|
|
|
2016-04-15 00:19:29 +08:00
|
|
|
typedef void mlxsw_reg_trans_cb_t(struct mlxsw_core *mlxsw_core, char *payload,
|
|
|
|
size_t payload_len, unsigned long cb_priv);
|
|
|
|
|
|
|
|
int mlxsw_reg_trans_query(struct mlxsw_core *mlxsw_core,
|
|
|
|
const struct mlxsw_reg_info *reg, char *payload,
|
|
|
|
struct list_head *bulk_list,
|
|
|
|
mlxsw_reg_trans_cb_t *cb, unsigned long cb_priv);
|
|
|
|
int mlxsw_reg_trans_write(struct mlxsw_core *mlxsw_core,
|
|
|
|
const struct mlxsw_reg_info *reg, char *payload,
|
|
|
|
struct list_head *bulk_list,
|
|
|
|
mlxsw_reg_trans_cb_t *cb, unsigned long cb_priv);
|
|
|
|
int mlxsw_reg_trans_bulk_wait(struct list_head *bulk_list);
|
|
|
|
|
2015-07-30 05:33:48 +08:00
|
|
|
int mlxsw_reg_query(struct mlxsw_core *mlxsw_core,
|
|
|
|
const struct mlxsw_reg_info *reg, char *payload);
|
|
|
|
int mlxsw_reg_write(struct mlxsw_core *mlxsw_core,
|
|
|
|
const struct mlxsw_reg_info *reg, char *payload);
|
|
|
|
|
2015-07-30 05:33:46 +08:00
|
|
|
struct mlxsw_rx_info {
|
2015-12-03 19:12:23 +08:00
|
|
|
bool is_lag;
|
|
|
|
union {
|
|
|
|
u16 sys_port;
|
|
|
|
u16 lag_id;
|
|
|
|
} u;
|
|
|
|
u8 lag_port_index;
|
2015-07-30 05:33:46 +08:00
|
|
|
int trap_id;
|
|
|
|
};
|
|
|
|
|
|
|
|
void mlxsw_core_skb_receive(struct mlxsw_core *mlxsw_core, struct sk_buff *skb,
|
|
|
|
struct mlxsw_rx_info *rx_info);
|
|
|
|
|
2015-12-03 19:12:23 +08:00
|
|
|
void mlxsw_core_lag_mapping_set(struct mlxsw_core *mlxsw_core,
|
|
|
|
u16 lag_id, u8 port_index, u8 local_port);
|
|
|
|
u8 mlxsw_core_lag_mapping_get(struct mlxsw_core *mlxsw_core,
|
|
|
|
u16 lag_id, u8 port_index);
|
|
|
|
void mlxsw_core_lag_mapping_clear(struct mlxsw_core *mlxsw_core,
|
|
|
|
u16 lag_id, u8 local_port);
|
|
|
|
|
2016-10-29 03:35:55 +08:00
|
|
|
void *mlxsw_core_port_driver_priv(struct mlxsw_core_port *mlxsw_core_port);
|
2019-03-24 18:14:31 +08:00
|
|
|
int mlxsw_core_port_init(struct mlxsw_core *mlxsw_core, u8 local_port,
|
|
|
|
u32 port_number, bool split,
|
2019-04-03 20:24:18 +08:00
|
|
|
u32 split_port_subnumber,
|
|
|
|
const unsigned char *switch_id,
|
|
|
|
unsigned char switch_id_len);
|
2016-10-29 03:35:55 +08:00
|
|
|
void mlxsw_core_port_fini(struct mlxsw_core *mlxsw_core, u8 local_port);
|
2019-09-16 23:04:21 +08:00
|
|
|
int mlxsw_core_cpu_port_init(struct mlxsw_core *mlxsw_core,
|
|
|
|
void *port_driver_priv,
|
|
|
|
const unsigned char *switch_id,
|
|
|
|
unsigned char switch_id_len);
|
|
|
|
void mlxsw_core_cpu_port_fini(struct mlxsw_core *mlxsw_core);
|
2016-10-29 03:35:57 +08:00
|
|
|
void mlxsw_core_port_eth_set(struct mlxsw_core *mlxsw_core, u8 local_port,
|
2019-03-24 18:14:31 +08:00
|
|
|
void *port_driver_priv, struct net_device *dev);
|
2016-10-29 03:35:58 +08:00
|
|
|
void mlxsw_core_port_ib_set(struct mlxsw_core *mlxsw_core, u8 local_port,
|
|
|
|
void *port_driver_priv);
|
2016-10-29 03:35:55 +08:00
|
|
|
void mlxsw_core_port_clear(struct mlxsw_core *mlxsw_core, u8 local_port,
|
|
|
|
void *port_driver_priv);
|
2016-10-29 03:35:58 +08:00
|
|
|
enum devlink_port_type mlxsw_core_port_type_get(struct mlxsw_core *mlxsw_core,
|
|
|
|
u8 local_port);
|
2019-03-28 20:56:38 +08:00
|
|
|
struct devlink_port *
|
|
|
|
mlxsw_core_port_devlink_port_get(struct mlxsw_core *mlxsw_core,
|
|
|
|
u8 local_port);
|
2019-10-31 17:42:08 +08:00
|
|
|
int mlxsw_core_module_max_width(struct mlxsw_core *mlxsw_core, u8 module);
|
2016-04-09 01:11:21 +08:00
|
|
|
|
2016-04-15 00:19:28 +08:00
|
|
|
int mlxsw_core_schedule_dw(struct delayed_work *dwork, unsigned long delay);
|
2017-02-06 23:20:10 +08:00
|
|
|
bool mlxsw_core_schedule_work(struct work_struct *work);
|
2016-12-03 23:45:00 +08:00
|
|
|
void mlxsw_core_flush_owq(void);
|
2019-03-03 17:12:11 +08:00
|
|
|
int mlxsw_core_resources_query(struct mlxsw_core *mlxsw_core, char *mbox,
|
|
|
|
struct mlxsw_res *res);
|
2016-04-15 00:19:28 +08:00
|
|
|
|
2015-07-30 05:33:46 +08:00
|
|
|
#define MLXSW_CONFIG_PROFILE_SWID_COUNT 8
|
|
|
|
|
|
|
|
struct mlxsw_swid_config {
|
|
|
|
u8 used_type:1,
|
|
|
|
used_properties:1;
|
|
|
|
u8 type;
|
|
|
|
u8 properties;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct mlxsw_config_profile {
|
|
|
|
u16 used_max_vepa_channels:1,
|
|
|
|
used_max_mid:1,
|
|
|
|
used_max_pgt:1,
|
|
|
|
used_max_system_port:1,
|
|
|
|
used_max_vlan_groups:1,
|
|
|
|
used_max_regions:1,
|
|
|
|
used_flood_tables:1,
|
|
|
|
used_flood_mode:1,
|
|
|
|
used_max_ib_mc:1,
|
|
|
|
used_max_pkey:1,
|
|
|
|
used_ar_sec:1,
|
2016-07-05 17:27:45 +08:00
|
|
|
used_adaptive_routing_group_cap:1,
|
2018-04-01 22:34:56 +08:00
|
|
|
used_kvd_sizes:1;
|
2015-07-30 05:33:46 +08:00
|
|
|
u8 max_vepa_channels;
|
|
|
|
u16 max_mid;
|
|
|
|
u16 max_pgt;
|
|
|
|
u16 max_system_port;
|
|
|
|
u16 max_vlan_groups;
|
|
|
|
u16 max_regions;
|
|
|
|
u8 max_flood_tables;
|
|
|
|
u8 max_vid_flood_tables;
|
|
|
|
u8 flood_mode;
|
2015-10-16 20:01:25 +08:00
|
|
|
u8 max_fid_offset_flood_tables;
|
|
|
|
u16 fid_offset_flood_table_size;
|
2015-10-16 20:01:24 +08:00
|
|
|
u8 max_fid_flood_tables;
|
|
|
|
u16 fid_flood_table_size;
|
2015-07-30 05:33:46 +08:00
|
|
|
u16 max_ib_mc;
|
|
|
|
u16 max_pkey;
|
|
|
|
u8 ar_sec;
|
|
|
|
u16 adaptive_routing_group_cap;
|
|
|
|
u8 arn;
|
2016-07-05 17:27:45 +08:00
|
|
|
u32 kvd_linear_size;
|
2016-09-20 17:16:52 +08:00
|
|
|
u8 kvd_hash_single_parts;
|
|
|
|
u8 kvd_hash_double_parts;
|
2015-07-30 05:33:46 +08:00
|
|
|
struct mlxsw_swid_config swid_config[MLXSW_CONFIG_PROFILE_SWID_COUNT];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct mlxsw_driver {
|
|
|
|
struct list_head list;
|
|
|
|
const char *kind;
|
|
|
|
size_t priv_size;
|
2016-04-09 01:11:23 +08:00
|
|
|
int (*init)(struct mlxsw_core *mlxsw_core,
|
2019-10-03 17:49:34 +08:00
|
|
|
const struct mlxsw_bus_info *mlxsw_bus_info,
|
|
|
|
struct netlink_ext_ack *extack);
|
2016-04-09 01:11:23 +08:00
|
|
|
void (*fini)(struct mlxsw_core *mlxsw_core);
|
2016-11-25 17:33:40 +08:00
|
|
|
int (*basic_trap_groups_set)(struct mlxsw_core *mlxsw_core);
|
2016-10-29 03:35:58 +08:00
|
|
|
int (*port_type_set)(struct mlxsw_core *mlxsw_core, u8 local_port,
|
|
|
|
enum devlink_port_type new_type);
|
2016-04-09 01:11:23 +08:00
|
|
|
int (*port_split)(struct mlxsw_core *mlxsw_core, u8 local_port,
|
2018-06-05 23:14:11 +08:00
|
|
|
unsigned int count, struct netlink_ext_ack *extack);
|
|
|
|
int (*port_unsplit)(struct mlxsw_core *mlxsw_core, u8 local_port,
|
|
|
|
struct netlink_ext_ack *extack);
|
2016-04-15 00:19:15 +08:00
|
|
|
int (*sb_pool_get)(struct mlxsw_core *mlxsw_core,
|
|
|
|
unsigned int sb_index, u16 pool_index,
|
|
|
|
struct devlink_sb_pool_info *pool_info);
|
|
|
|
int (*sb_pool_set)(struct mlxsw_core *mlxsw_core,
|
|
|
|
unsigned int sb_index, u16 pool_index, u32 size,
|
2019-04-22 20:08:41 +08:00
|
|
|
enum devlink_sb_threshold_type threshold_type,
|
|
|
|
struct netlink_ext_ack *extack);
|
2016-04-15 00:19:15 +08:00
|
|
|
int (*sb_port_pool_get)(struct mlxsw_core_port *mlxsw_core_port,
|
|
|
|
unsigned int sb_index, u16 pool_index,
|
|
|
|
u32 *p_threshold);
|
|
|
|
int (*sb_port_pool_set)(struct mlxsw_core_port *mlxsw_core_port,
|
|
|
|
unsigned int sb_index, u16 pool_index,
|
2019-04-22 20:08:41 +08:00
|
|
|
u32 threshold, struct netlink_ext_ack *extack);
|
2016-04-15 00:19:15 +08:00
|
|
|
int (*sb_tc_pool_bind_get)(struct mlxsw_core_port *mlxsw_core_port,
|
|
|
|
unsigned int sb_index, u16 tc_index,
|
|
|
|
enum devlink_sb_pool_type pool_type,
|
|
|
|
u16 *p_pool_index, u32 *p_threshold);
|
|
|
|
int (*sb_tc_pool_bind_set)(struct mlxsw_core_port *mlxsw_core_port,
|
|
|
|
unsigned int sb_index, u16 tc_index,
|
|
|
|
enum devlink_sb_pool_type pool_type,
|
2019-04-22 20:08:41 +08:00
|
|
|
u16 pool_index, u32 threshold,
|
|
|
|
struct netlink_ext_ack *extack);
|
2016-04-15 00:19:25 +08:00
|
|
|
int (*sb_occ_snapshot)(struct mlxsw_core *mlxsw_core,
|
|
|
|
unsigned int sb_index);
|
|
|
|
int (*sb_occ_max_clear)(struct mlxsw_core *mlxsw_core,
|
|
|
|
unsigned int sb_index);
|
|
|
|
int (*sb_occ_port_pool_get)(struct mlxsw_core_port *mlxsw_core_port,
|
|
|
|
unsigned int sb_index, u16 pool_index,
|
|
|
|
u32 *p_cur, u32 *p_max);
|
|
|
|
int (*sb_occ_tc_port_bind_get)(struct mlxsw_core_port *mlxsw_core_port,
|
|
|
|
unsigned int sb_index, u16 tc_index,
|
|
|
|
enum devlink_sb_pool_type pool_type,
|
|
|
|
u32 *p_cur, u32 *p_max);
|
2019-06-04 21:40:37 +08:00
|
|
|
int (*flash_update)(struct mlxsw_core *mlxsw_core,
|
|
|
|
const char *file_name, const char *component,
|
|
|
|
struct netlink_ext_ack *extack);
|
2019-08-21 15:19:35 +08:00
|
|
|
int (*trap_init)(struct mlxsw_core *mlxsw_core,
|
|
|
|
const struct devlink_trap *trap, void *trap_ctx);
|
|
|
|
void (*trap_fini)(struct mlxsw_core *mlxsw_core,
|
|
|
|
const struct devlink_trap *trap, void *trap_ctx);
|
|
|
|
int (*trap_action_set)(struct mlxsw_core *mlxsw_core,
|
|
|
|
const struct devlink_trap *trap,
|
|
|
|
enum devlink_trap_action action);
|
|
|
|
int (*trap_group_init)(struct mlxsw_core *mlxsw_core,
|
|
|
|
const struct devlink_trap_group *group);
|
2015-07-30 05:33:46 +08:00
|
|
|
void (*txhdr_construct)(struct sk_buff *skb,
|
|
|
|
const struct mlxsw_tx_info *tx_info);
|
2018-01-15 15:59:07 +08:00
|
|
|
int (*resources_register)(struct mlxsw_core *mlxsw_core);
|
2018-01-15 15:59:10 +08:00
|
|
|
int (*kvd_sizes_get)(struct mlxsw_core *mlxsw_core,
|
|
|
|
const struct mlxsw_config_profile *profile,
|
|
|
|
u64 *p_single_size, u64 *p_double_size,
|
|
|
|
u64 *p_linear_size);
|
2018-12-03 15:59:02 +08:00
|
|
|
int (*params_register)(struct mlxsw_core *mlxsw_core);
|
|
|
|
void (*params_unregister)(struct mlxsw_core *mlxsw_core);
|
mlxsw: pci: PTP: Hook into packet transmit path
On Spectrum-1, timestamps are delivered separately from the packets, and
need to paired up. Therefore, at some point after mlxsw_sp_port_xmit()
is invoked, it is necessary to involve the chip-specific driver code to
allow it to do the necessary bookkeeping and matching.
On Spectrum-2, timestamps are delivered in CQE. For that reason,
position the point of driver involvement into mlxsw_pci_cqe_sdq_handle()
to make it hopefully easier to extend for Spectrum-2 in the future.
To tell the driver what port the packet was sent on, keep tx_info
in SKB control buffer.
Introduce a new driver core interface mlxsw_core_ptp_transmitted(), a
driver callback ptp_transmitted, and a PTP op transmitted. The callee is
responsible for taking care of releasing the SKB passed to the new
interfaces, and correspondingly have the new stub callbacks just call
dev_kfree_skb_any().
Follow-up patches will introduce the actual content into
mlxsw_sp1_ptp_transmitted() in particular.
Signed-off-by: Petr Machata <petrm@mellanox.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2019-06-30 14:04:53 +08:00
|
|
|
|
|
|
|
/* Notify a driver that a timestamped packet was transmitted. Driver
|
|
|
|
* is responsible for freeing the passed-in SKB.
|
|
|
|
*/
|
|
|
|
void (*ptp_transmitted)(struct mlxsw_core *mlxsw_core,
|
|
|
|
struct sk_buff *skb, u8 local_port);
|
|
|
|
|
2015-07-30 05:33:46 +08:00
|
|
|
u8 txhdr_len;
|
|
|
|
const struct mlxsw_config_profile *profile;
|
2018-04-01 22:34:57 +08:00
|
|
|
bool res_query_enabled;
|
2015-07-30 05:33:46 +08:00
|
|
|
};
|
|
|
|
|
2018-01-15 15:59:10 +08:00
|
|
|
int mlxsw_core_kvd_sizes_get(struct mlxsw_core *mlxsw_core,
|
|
|
|
const struct mlxsw_config_profile *profile,
|
|
|
|
u64 *p_single_size, u64 *p_double_size,
|
|
|
|
u64 *p_linear_size);
|
|
|
|
|
2018-12-18 23:59:20 +08:00
|
|
|
void mlxsw_core_fw_flash_start(struct mlxsw_core *mlxsw_core);
|
|
|
|
void mlxsw_core_fw_flash_end(struct mlxsw_core *mlxsw_core);
|
|
|
|
|
2019-06-11 23:45:05 +08:00
|
|
|
u32 mlxsw_core_read_frc_h(struct mlxsw_core *mlxsw_core);
|
|
|
|
u32 mlxsw_core_read_frc_l(struct mlxsw_core *mlxsw_core);
|
2019-11-12 14:48:29 +08:00
|
|
|
|
|
|
|
void mlxsw_core_emad_string_tlv_enable(struct mlxsw_core *mlxsw_core);
|
2019-06-11 23:45:05 +08:00
|
|
|
|
2016-10-21 22:07:23 +08:00
|
|
|
bool mlxsw_core_res_valid(struct mlxsw_core *mlxsw_core,
|
|
|
|
enum mlxsw_res_id res_id);
|
2016-09-20 17:16:52 +08:00
|
|
|
|
2018-04-01 22:34:55 +08:00
|
|
|
#define MLXSW_CORE_RES_VALID(mlxsw_core, short_res_id) \
|
|
|
|
mlxsw_core_res_valid(mlxsw_core, MLXSW_RES_ID_##short_res_id)
|
2016-10-21 22:07:23 +08:00
|
|
|
|
|
|
|
u64 mlxsw_core_res_get(struct mlxsw_core *mlxsw_core,
|
|
|
|
enum mlxsw_res_id res_id);
|
2016-07-21 18:03:09 +08:00
|
|
|
|
2018-04-01 22:34:55 +08:00
|
|
|
#define MLXSW_CORE_RES_GET(mlxsw_core, short_res_id) \
|
|
|
|
mlxsw_core_res_get(mlxsw_core, MLXSW_RES_ID_##short_res_id)
|
2016-07-21 18:03:09 +08:00
|
|
|
|
2019-10-03 17:49:32 +08:00
|
|
|
static inline struct net *mlxsw_core_net(struct mlxsw_core *mlxsw_core)
|
|
|
|
{
|
|
|
|
return devlink_net(priv_to_devlink(mlxsw_core));
|
|
|
|
}
|
|
|
|
|
2016-11-16 22:20:43 +08:00
|
|
|
#define MLXSW_BUS_F_TXRX BIT(0)
|
2018-05-27 14:56:15 +08:00
|
|
|
#define MLXSW_BUS_F_RESET BIT(1)
|
2016-11-16 22:20:43 +08:00
|
|
|
|
2015-07-30 05:33:46 +08:00
|
|
|
struct mlxsw_bus {
|
|
|
|
const char *kind;
|
|
|
|
int (*init)(void *bus_priv, struct mlxsw_core *mlxsw_core,
|
2016-07-21 18:03:09 +08:00
|
|
|
const struct mlxsw_config_profile *profile,
|
2016-10-21 22:07:23 +08:00
|
|
|
struct mlxsw_res *res);
|
2015-07-30 05:33:46 +08:00
|
|
|
void (*fini)(void *bus_priv);
|
2015-08-06 22:41:56 +08:00
|
|
|
bool (*skb_transmit_busy)(void *bus_priv,
|
|
|
|
const struct mlxsw_tx_info *tx_info);
|
2015-07-30 05:33:46 +08:00
|
|
|
int (*skb_transmit)(void *bus_priv, struct sk_buff *skb,
|
|
|
|
const struct mlxsw_tx_info *tx_info);
|
|
|
|
int (*cmd_exec)(void *bus_priv, u16 opcode, u8 opcode_mod,
|
|
|
|
u32 in_mod, bool out_mbox_direct,
|
|
|
|
char *in_mbox, size_t in_mbox_size,
|
|
|
|
char *out_mbox, size_t out_mbox_size,
|
|
|
|
u8 *p_status);
|
2019-06-11 23:45:05 +08:00
|
|
|
u32 (*read_frc_h)(void *bus_priv);
|
|
|
|
u32 (*read_frc_l)(void *bus_priv);
|
2016-11-16 22:20:43 +08:00
|
|
|
u8 features;
|
2015-07-30 05:33:46 +08:00
|
|
|
};
|
|
|
|
|
2017-05-24 03:56:28 +08:00
|
|
|
struct mlxsw_fw_rev {
|
|
|
|
u16 major;
|
|
|
|
u16 minor;
|
|
|
|
u16 subminor;
|
2018-08-09 16:59:09 +08:00
|
|
|
u16 can_reset_minor;
|
2017-05-24 03:56:28 +08:00
|
|
|
};
|
|
|
|
|
2015-07-30 05:33:46 +08:00
|
|
|
struct mlxsw_bus_info {
|
|
|
|
const char *device_kind;
|
|
|
|
const char *device_name;
|
|
|
|
struct device *dev;
|
2017-05-24 03:56:28 +08:00
|
|
|
struct mlxsw_fw_rev fw_rev;
|
2015-07-30 05:33:46 +08:00
|
|
|
u8 vsd[MLXSW_CMD_BOARDINFO_VSD_LEN];
|
|
|
|
u8 psid[MLXSW_CMD_BOARDINFO_PSID_LEN];
|
2019-06-11 23:45:05 +08:00
|
|
|
u8 low_frequency:1,
|
|
|
|
read_frc_capable:1;
|
2015-07-30 05:33:46 +08:00
|
|
|
};
|
|
|
|
|
2015-11-27 20:45:57 +08:00
|
|
|
struct mlxsw_hwmon;
|
|
|
|
|
|
|
|
#ifdef CONFIG_MLXSW_CORE_HWMON
|
|
|
|
|
|
|
|
int mlxsw_hwmon_init(struct mlxsw_core *mlxsw_core,
|
|
|
|
const struct mlxsw_bus_info *mlxsw_bus_info,
|
|
|
|
struct mlxsw_hwmon **p_hwmon);
|
|
|
|
void mlxsw_hwmon_fini(struct mlxsw_hwmon *mlxsw_hwmon);
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
static inline int mlxsw_hwmon_init(struct mlxsw_core *mlxsw_core,
|
|
|
|
const struct mlxsw_bus_info *mlxsw_bus_info,
|
|
|
|
struct mlxsw_hwmon **p_hwmon)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-10-17 16:05:45 +08:00
|
|
|
static inline void mlxsw_hwmon_fini(struct mlxsw_hwmon *mlxsw_hwmon)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-11-27 20:45:57 +08:00
|
|
|
#endif
|
|
|
|
|
2016-11-22 18:24:13 +08:00
|
|
|
struct mlxsw_thermal;
|
|
|
|
|
|
|
|
#ifdef CONFIG_MLXSW_CORE_THERMAL
|
|
|
|
|
|
|
|
int mlxsw_thermal_init(struct mlxsw_core *mlxsw_core,
|
|
|
|
const struct mlxsw_bus_info *mlxsw_bus_info,
|
|
|
|
struct mlxsw_thermal **p_thermal);
|
|
|
|
void mlxsw_thermal_fini(struct mlxsw_thermal *thermal);
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
static inline int mlxsw_thermal_init(struct mlxsw_core *mlxsw_core,
|
|
|
|
const struct mlxsw_bus_info *mlxsw_bus_info,
|
|
|
|
struct mlxsw_thermal **p_thermal)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void mlxsw_thermal_fini(struct mlxsw_thermal *thermal)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2019-02-07 19:22:55 +08:00
|
|
|
enum mlxsw_devlink_param_id {
|
|
|
|
MLXSW_DEVLINK_PARAM_ID_BASE = DEVLINK_PARAM_GENERIC_ID_MAX,
|
|
|
|
MLXSW_DEVLINK_PARAM_ID_ACL_REGION_REHASH_INTERVAL,
|
|
|
|
};
|
|
|
|
|
2019-06-30 14:04:52 +08:00
|
|
|
struct mlxsw_skb_cb {
|
mlxsw: pci: PTP: Hook into packet transmit path
On Spectrum-1, timestamps are delivered separately from the packets, and
need to paired up. Therefore, at some point after mlxsw_sp_port_xmit()
is invoked, it is necessary to involve the chip-specific driver code to
allow it to do the necessary bookkeeping and matching.
On Spectrum-2, timestamps are delivered in CQE. For that reason,
position the point of driver involvement into mlxsw_pci_cqe_sdq_handle()
to make it hopefully easier to extend for Spectrum-2 in the future.
To tell the driver what port the packet was sent on, keep tx_info
in SKB control buffer.
Introduce a new driver core interface mlxsw_core_ptp_transmitted(), a
driver callback ptp_transmitted, and a PTP op transmitted. The callee is
responsible for taking care of releasing the SKB passed to the new
interfaces, and correspondingly have the new stub callbacks just call
dev_kfree_skb_any().
Follow-up patches will introduce the actual content into
mlxsw_sp1_ptp_transmitted() in particular.
Signed-off-by: Petr Machata <petrm@mellanox.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2019-06-30 14:04:53 +08:00
|
|
|
struct mlxsw_tx_info tx_info;
|
2019-06-30 14:04:52 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
static inline struct mlxsw_skb_cb *mlxsw_skb_cb(struct sk_buff *skb)
|
|
|
|
{
|
|
|
|
BUILD_BUG_ON(sizeof(mlxsw_skb_cb) > sizeof(skb->cb));
|
|
|
|
return (struct mlxsw_skb_cb *) skb->cb;
|
|
|
|
}
|
|
|
|
|
2015-07-30 05:33:46 +08:00
|
|
|
#endif
|