Skip to content

Commit e281682

Browse files
Saeed Mahameeddavem330
authored andcommitted
net/mlx5_core: HW data structs/types definitions cleanup
mlx5_ifc.h was heavily modified here since it is now generated by a script from the device specification (PRM rev 0.25). This specification is backward compatible to existing hardware. Some structures/fields were added here in order to enable the Ethernet functionality of the driver. Signed-off-by: Saeed Mahameed <saeedm@mellanox.com> Signed-off-by: Amir Vadai <amirv@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent db058a1 commit e281682

File tree

9 files changed

+6705
-110
lines changed

9 files changed

+6705
-110
lines changed

drivers/net/ethernet/mellanox/mlx5/core/cmd.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -390,8 +390,17 @@ const char *mlx5_command_str(int command)
390390
case MLX5_CMD_OP_ARM_RQ:
391391
return "ARM_RQ";
392392

393-
case MLX5_CMD_OP_RESIZE_SRQ:
394-
return "RESIZE_SRQ";
393+
case MLX5_CMD_OP_CREATE_XRC_SRQ:
394+
return "CREATE_XRC_SRQ";
395+
396+
case MLX5_CMD_OP_DESTROY_XRC_SRQ:
397+
return "DESTROY_XRC_SRQ";
398+
399+
case MLX5_CMD_OP_QUERY_XRC_SRQ:
400+
return "QUERY_XRC_SRQ";
401+
402+
case MLX5_CMD_OP_ARM_XRC_SRQ:
403+
return "ARM_XRC_SRQ";
395404

396405
case MLX5_CMD_OP_ALLOC_PD:
397406
return "ALLOC_PD";
@@ -408,8 +417,8 @@ const char *mlx5_command_str(int command)
408417
case MLX5_CMD_OP_ATTACH_TO_MCG:
409418
return "ATTACH_TO_MCG";
410419

411-
case MLX5_CMD_OP_DETACH_FROM_MCG:
412-
return "DETACH_FROM_MCG";
420+
case MLX5_CMD_OP_DETTACH_FROM_MCG:
421+
return "DETTACH_FROM_MCG";
413422

414423
case MLX5_CMD_OP_ALLOC_XRCD:
415424
return "ALLOC_XRCD";

drivers/net/ethernet/mellanox/mlx5/core/fw.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ int mlx5_query_odp_caps(struct mlx5_core_dev *dev, struct mlx5_odp_caps *caps)
9595
goto out;
9696
}
9797

98-
memcpy(caps, MLX5_ADDR_OF(query_hca_cap_out, out, capability_struct),
98+
memcpy(caps, MLX5_ADDR_OF(query_hca_cap_out, out, capability),
9999
sizeof(*caps));
100100

101101
mlx5_core_dbg(dev, "on-demand paging capabilities:\nrc: %08x\nuc: %08x\nud: %08x\n",

drivers/net/ethernet/mellanox/mlx5/core/main.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -319,8 +319,7 @@ static void fw2drv_caps(struct mlx5_caps *caps, void *out)
319319
gen->max_srq_wqes = 1 << MLX5_GET_PR(cmd_hca_cap, out, log_max_srq_sz);
320320
gen->max_wqes = 1 << MLX5_GET_PR(cmd_hca_cap, out, log_max_qp_sz);
321321
gen->log_max_qp = MLX5_GET_PR(cmd_hca_cap, out, log_max_qp);
322-
gen->log_max_strq = MLX5_GET_PR(cmd_hca_cap, out, log_max_strq_sz);
323-
gen->log_max_srq = MLX5_GET_PR(cmd_hca_cap, out, log_max_srqs);
322+
gen->log_max_srq = MLX5_GET_PR(cmd_hca_cap, out, log_max_srq);
324323
gen->max_cqes = 1 << MLX5_GET_PR(cmd_hca_cap, out, log_max_cq_sz);
325324
gen->log_max_cq = MLX5_GET_PR(cmd_hca_cap, out, log_max_cq);
326325
gen->max_eqes = 1 << MLX5_GET_PR(cmd_hca_cap, out, log_max_eq_sz);
@@ -391,7 +390,7 @@ int mlx5_core_get_caps(struct mlx5_core_dev *dev, struct mlx5_caps *caps,
391390
goto query_ex;
392391
}
393392
mlx5_core_dbg(dev, "%s\n", caps_opmod_str(opmod));
394-
fw2drv_caps(caps, MLX5_ADDR_OF(query_hca_cap_out, out, capability_struct));
393+
fw2drv_caps(caps, MLX5_ADDR_OF(query_hca_cap_out, out, capability));
395394

396395
query_ex:
397396
kfree(out);
@@ -453,7 +452,7 @@ static int handle_hca_cap(struct mlx5_core_dev *dev)
453452
/* disable checksum */
454453
cur_caps->gen.flags &= ~MLX5_DEV_CAP_FLAG_CMDIF_CSUM;
455454

456-
copy_rw_fields(MLX5_ADDR_OF(set_hca_cap_in, set_ctx, hca_capability_struct),
455+
copy_rw_fields(MLX5_ADDR_OF(set_hca_cap_in, set_ctx, capability),
457456
cur_caps);
458457
err = set_caps(dev, set_ctx, set_sz);
459458

drivers/net/ethernet/mellanox/mlx5/core/mcg.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ int mlx5_core_detach_mcg(struct mlx5_core_dev *dev, union ib_gid *mgid, u32 qpn)
9191

9292
memset(&in, 0, sizeof(in));
9393
memset(&out, 0, sizeof(out));
94-
in.hdr.opcode = cpu_to_be16(MLX5_CMD_OP_DETACH_FROM_MCG);
94+
in.hdr.opcode = cpu_to_be16(MLX5_CMD_OP_DETTACH_FROM_MCG);
9595
memcpy(in.gid, mgid, sizeof(*mgid));
9696
in.qpn = cpu_to_be32(qpn);
9797
err = mlx5_cmd_exec(dev, &in, sizeof(in), &out, sizeof(out));

drivers/net/ethernet/mellanox/mlx5/core/uar.c

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,3 +223,40 @@ int mlx5_free_uuars(struct mlx5_core_dev *dev, struct mlx5_uuar_info *uuari)
223223

224224
return 0;
225225
}
226+
227+
int mlx5_alloc_map_uar(struct mlx5_core_dev *mdev, struct mlx5_uar *uar)
228+
{
229+
phys_addr_t pfn;
230+
phys_addr_t uar_bar_start;
231+
int err;
232+
233+
err = mlx5_cmd_alloc_uar(mdev, &uar->index);
234+
if (err) {
235+
mlx5_core_warn(mdev, "mlx5_cmd_alloc_uar() failed, %d\n", err);
236+
return err;
237+
}
238+
239+
uar_bar_start = pci_resource_start(mdev->pdev, 0);
240+
pfn = (uar_bar_start >> PAGE_SHIFT) + uar->index;
241+
uar->map = ioremap(pfn << PAGE_SHIFT, PAGE_SIZE);
242+
if (!uar->map) {
243+
mlx5_core_warn(mdev, "ioremap() failed, %d\n", err);
244+
err = -ENOMEM;
245+
goto err_free_uar;
246+
}
247+
248+
return 0;
249+
250+
err_free_uar:
251+
mlx5_cmd_free_uar(mdev, uar->index);
252+
253+
return err;
254+
}
255+
EXPORT_SYMBOL(mlx5_alloc_map_uar);
256+
257+
void mlx5_unmap_free_uar(struct mlx5_core_dev *mdev, struct mlx5_uar *uar)
258+
{
259+
iounmap(uar->map);
260+
mlx5_cmd_free_uar(mdev, uar->index);
261+
}
262+
EXPORT_SYMBOL(mlx5_unmap_free_uar);

include/linux/mlx5/device.h

Lines changed: 109 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535

3636
#include <linux/types.h>
3737
#include <rdma/ib_verbs.h>
38+
#include <linux/mlx5/mlx5_ifc.h>
3839

3940
#if defined(__LITTLE_ENDIAN)
4041
#define MLX5_SET_HOST_ENDIANNESS 0
@@ -70,6 +71,14 @@
7071
<< __mlx5_dw_bit_off(typ, fld))); \
7172
} while (0)
7273

74+
#define MLX5_SET_TO_ONES(typ, p, fld) do { \
75+
BUILD_BUG_ON(__mlx5_st_sz_bits(typ) % 32); \
76+
*((__be32 *)(p) + __mlx5_dw_off(typ, fld)) = \
77+
cpu_to_be32((be32_to_cpu(*((__be32 *)(p) + __mlx5_dw_off(typ, fld))) & \
78+
(~__mlx5_dw_mask(typ, fld))) | ((__mlx5_mask(typ, fld)) \
79+
<< __mlx5_dw_bit_off(typ, fld))); \
80+
} while (0)
81+
7382
#define MLX5_GET(typ, p, fld) ((be32_to_cpu(*((__be32 *)(p) +\
7483
__mlx5_dw_off(typ, fld))) >> __mlx5_dw_bit_off(typ, fld)) & \
7584
__mlx5_mask(typ, fld))
@@ -264,6 +273,7 @@ enum {
264273
MLX5_OPCODE_RDMA_WRITE_IMM = 0x09,
265274
MLX5_OPCODE_SEND = 0x0a,
266275
MLX5_OPCODE_SEND_IMM = 0x0b,
276+
MLX5_OPCODE_LSO = 0x0e,
267277
MLX5_OPCODE_RDMA_READ = 0x10,
268278
MLX5_OPCODE_ATOMIC_CS = 0x11,
269279
MLX5_OPCODE_ATOMIC_FA = 0x12,
@@ -541,6 +551,10 @@ struct mlx5_cmd_prot_block {
541551
u8 sig;
542552
};
543553

554+
enum {
555+
MLX5_CQE_SYND_FLUSHED_IN_ERROR = 5,
556+
};
557+
544558
struct mlx5_err_cqe {
545559
u8 rsvd0[32];
546560
__be32 srqn;
@@ -554,13 +568,22 @@ struct mlx5_err_cqe {
554568
};
555569

556570
struct mlx5_cqe64 {
557-
u8 rsvd0[17];
571+
u8 rsvd0[4];
572+
u8 lro_tcppsh_abort_dupack;
573+
u8 lro_min_ttl;
574+
__be16 lro_tcp_win;
575+
__be32 lro_ack_seq_num;
576+
__be32 rss_hash_result;
577+
u8 rss_hash_type;
558578
u8 ml_path;
559-
u8 rsvd20[4];
579+
u8 rsvd20[2];
580+
__be16 check_sum;
560581
__be16 slid;
561582
__be32 flags_rqpn;
562-
u8 rsvd28[4];
563-
__be32 srqn;
583+
u8 hds_ip_ext;
584+
u8 l4_hdr_type_etc;
585+
__be16 vlan_info;
586+
__be32 srqn; /* [31:24]: lro_num_seg, [23:0]: srqn */
564587
__be32 imm_inval_pkey;
565588
u8 rsvd40[4];
566589
__be32 byte_cnt;
@@ -571,6 +594,40 @@ struct mlx5_cqe64 {
571594
u8 op_own;
572595
};
573596

597+
static inline int get_cqe_lro_tcppsh(struct mlx5_cqe64 *cqe)
598+
{
599+
return (cqe->lro_tcppsh_abort_dupack >> 6) & 1;
600+
}
601+
602+
static inline u8 get_cqe_l4_hdr_type(struct mlx5_cqe64 *cqe)
603+
{
604+
return (cqe->l4_hdr_type_etc >> 4) & 0x7;
605+
}
606+
607+
static inline int cqe_has_vlan(struct mlx5_cqe64 *cqe)
608+
{
609+
return !!(cqe->l4_hdr_type_etc & 0x1);
610+
}
611+
612+
enum {
613+
CQE_L4_HDR_TYPE_NONE = 0x0,
614+
CQE_L4_HDR_TYPE_TCP_NO_ACK = 0x1,
615+
CQE_L4_HDR_TYPE_UDP = 0x2,
616+
CQE_L4_HDR_TYPE_TCP_ACK_NO_DATA = 0x3,
617+
CQE_L4_HDR_TYPE_TCP_ACK_AND_DATA = 0x4,
618+
};
619+
620+
enum {
621+
CQE_RSS_HTYPE_IP = 0x3 << 6,
622+
CQE_RSS_HTYPE_L4 = 0x3 << 2,
623+
};
624+
625+
enum {
626+
CQE_L2_OK = 1 << 0,
627+
CQE_L3_OK = 1 << 1,
628+
CQE_L4_OK = 1 << 2,
629+
};
630+
574631
struct mlx5_sig_err_cqe {
575632
u8 rsvd0[16];
576633
__be32 expected_trans_sig;
@@ -996,4 +1053,52 @@ struct mlx5_destroy_psv_out {
9961053
u8 rsvd[8];
9971054
};
9981055

1056+
#define MLX5_CMD_OP_MAX 0x920
1057+
1058+
enum {
1059+
VPORT_STATE_DOWN = 0x0,
1060+
VPORT_STATE_UP = 0x1,
1061+
};
1062+
1063+
enum {
1064+
MLX5_L3_PROT_TYPE_IPV4 = 0,
1065+
MLX5_L3_PROT_TYPE_IPV6 = 1,
1066+
};
1067+
1068+
enum {
1069+
MLX5_L4_PROT_TYPE_TCP = 0,
1070+
MLX5_L4_PROT_TYPE_UDP = 1,
1071+
};
1072+
1073+
enum {
1074+
MLX5_HASH_FIELD_SEL_SRC_IP = 1 << 0,
1075+
MLX5_HASH_FIELD_SEL_DST_IP = 1 << 1,
1076+
MLX5_HASH_FIELD_SEL_L4_SPORT = 1 << 2,
1077+
MLX5_HASH_FIELD_SEL_L4_DPORT = 1 << 3,
1078+
MLX5_HASH_FIELD_SEL_IPSEC_SPI = 1 << 4,
1079+
};
1080+
1081+
enum {
1082+
MLX5_MATCH_OUTER_HEADERS = 1 << 0,
1083+
MLX5_MATCH_MISC_PARAMETERS = 1 << 1,
1084+
MLX5_MATCH_INNER_HEADERS = 1 << 2,
1085+
1086+
};
1087+
1088+
enum {
1089+
MLX5_FLOW_TABLE_TYPE_NIC_RCV = 0,
1090+
MLX5_FLOW_TABLE_TYPE_ESWITCH = 4,
1091+
};
1092+
1093+
enum {
1094+
MLX5_FLOW_CONTEXT_DEST_TYPE_VPORT = 0,
1095+
MLX5_FLOW_CONTEXT_DEST_TYPE_FLOW_TABLE = 1,
1096+
MLX5_FLOW_CONTEXT_DEST_TYPE_TIR = 2,
1097+
};
1098+
1099+
enum {
1100+
MLX5_RQC_RQ_TYPE_MEMORY_RQ_INLINE = 0x0,
1101+
MLX5_RQC_RQ_TYPE_MEMORY_RQ_RPM = 0x1,
1102+
};
1103+
9991104
#endif /* MLX5_DEVICE_H */

include/linux/mlx5/driver.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444

4545
#include <linux/mlx5/device.h>
4646
#include <linux/mlx5/doorbell.h>
47-
#include <linux/mlx5/mlx5_ifc.h>
4847

4948
enum {
5049
MLX5_BOARD_ID_LEN = 64,
@@ -278,7 +277,6 @@ struct mlx5_general_caps {
278277
u8 log_max_mkey;
279278
u8 log_max_pd;
280279
u8 log_max_srq;
281-
u8 log_max_strq;
282280
u8 log_max_mrw_sz;
283281
u8 log_max_bsf_list_size;
284282
u8 log_max_klm_list_size;
@@ -664,6 +662,8 @@ int mlx5_cmd_alloc_uar(struct mlx5_core_dev *dev, u32 *uarn);
664662
int mlx5_cmd_free_uar(struct mlx5_core_dev *dev, u32 uarn);
665663
int mlx5_alloc_uuars(struct mlx5_core_dev *dev, struct mlx5_uuar_info *uuari);
666664
int mlx5_free_uuars(struct mlx5_core_dev *dev, struct mlx5_uuar_info *uuari);
665+
int mlx5_alloc_map_uar(struct mlx5_core_dev *mdev, struct mlx5_uar *uar);
666+
void mlx5_unmap_free_uar(struct mlx5_core_dev *mdev, struct mlx5_uar *uar);
667667
void mlx5_health_cleanup(void);
668668
void __init mlx5_health_init(void);
669669
void mlx5_start_health_poll(struct mlx5_core_dev *dev);

0 commit comments

Comments
 (0)