Skip to content

Commit f5d88f5

Browse files
jpirkodavem330
authored andcommitted
mlxsw: reg: Add Switch FDB Notification register definition
Add SFN register which is used to poll for newly added and aged-out FDB entries. Signed-off-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 236033b commit f5d88f5

File tree

1 file changed

+101
-0
lines changed
  • drivers/net/ethernet/mellanox/mlxsw

1 file changed

+101
-0
lines changed

drivers/net/ethernet/mellanox/mlxsw/reg.h

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,105 @@ mlxsw_reg_sfd_uc_unpack(char *payload, int rec_index,
371371
*p_local_port = mlxsw_reg_sfd_uc_system_port_get(payload, rec_index);
372372
}
373373

374+
/* SFN - Switch FDB Notification Register
375+
* -------------------------------------------
376+
* The switch provides notifications on newly learned FDB entries and
377+
* aged out entries. The notifications can be polled by software.
378+
*/
379+
#define MLXSW_REG_SFN_ID 0x200B
380+
#define MLXSW_REG_SFN_BASE_LEN 0x10 /* base length, without records */
381+
#define MLXSW_REG_SFN_REC_LEN 0x10 /* record length */
382+
#define MLXSW_REG_SFN_REC_MAX_COUNT 64
383+
#define MLXSW_REG_SFN_LEN (MLXSW_REG_SFN_BASE_LEN + \
384+
MLXSW_REG_SFN_REC_LEN * MLXSW_REG_SFN_REC_MAX_COUNT)
385+
386+
static const struct mlxsw_reg_info mlxsw_reg_sfn = {
387+
.id = MLXSW_REG_SFN_ID,
388+
.len = MLXSW_REG_SFN_LEN,
389+
};
390+
391+
/* reg_sfn_swid
392+
* Switch partition ID.
393+
* Access: Index
394+
*/
395+
MLXSW_ITEM32(reg, sfn, swid, 0x00, 24, 8);
396+
397+
/* reg_sfn_num_rec
398+
* Request: Number of learned notifications and aged-out notification
399+
* records requested.
400+
* Response: Number of notification records returned (must be smaller
401+
* than or equal to the value requested)
402+
* Ranges 0..64
403+
* Access: OP
404+
*/
405+
MLXSW_ITEM32(reg, sfn, num_rec, 0x04, 0, 8);
406+
407+
static inline void mlxsw_reg_sfn_pack(char *payload)
408+
{
409+
MLXSW_REG_ZERO(sfn, payload);
410+
mlxsw_reg_sfn_swid_set(payload, 0);
411+
mlxsw_reg_sfn_num_rec_set(payload, MLXSW_REG_SFN_REC_MAX_COUNT);
412+
}
413+
414+
/* reg_sfn_rec_swid
415+
* Switch partition ID.
416+
* Access: RO
417+
*/
418+
MLXSW_ITEM32_INDEXED(reg, sfn, rec_swid, MLXSW_REG_SFN_BASE_LEN, 24, 8,
419+
MLXSW_REG_SFN_REC_LEN, 0x00, false);
420+
421+
enum mlxsw_reg_sfn_rec_type {
422+
/* MAC addresses learned on a regular port. */
423+
MLXSW_REG_SFN_REC_TYPE_LEARNED_MAC = 0x5,
424+
/* Aged-out MAC address on a regular port */
425+
MLXSW_REG_SFN_REC_TYPE_AGED_OUT_MAC = 0x7,
426+
};
427+
428+
/* reg_sfn_rec_type
429+
* Notification record type.
430+
* Access: RO
431+
*/
432+
MLXSW_ITEM32_INDEXED(reg, sfn, rec_type, MLXSW_REG_SFN_BASE_LEN, 20, 4,
433+
MLXSW_REG_SFN_REC_LEN, 0x00, false);
434+
435+
/* reg_sfn_rec_mac
436+
* MAC address.
437+
* Access: RO
438+
*/
439+
MLXSW_ITEM_BUF_INDEXED(reg, sfn, rec_mac, MLXSW_REG_SFN_BASE_LEN, 6,
440+
MLXSW_REG_SFN_REC_LEN, 0x02);
441+
442+
/* reg_sfd_mac_sub_port
443+
* VEPA channel on the local port.
444+
* 0 if multichannel VEPA is not enabled.
445+
* Access: RO
446+
*/
447+
MLXSW_ITEM32_INDEXED(reg, sfn, mac_sub_port, MLXSW_REG_SFN_BASE_LEN, 16, 8,
448+
MLXSW_REG_SFN_REC_LEN, 0x08, false);
449+
450+
/* reg_sfd_mac_fid
451+
* Filtering identifier.
452+
* Access: RO
453+
*/
454+
MLXSW_ITEM32_INDEXED(reg, sfn, mac_fid, MLXSW_REG_SFN_BASE_LEN, 0, 16,
455+
MLXSW_REG_SFN_REC_LEN, 0x08, false);
456+
457+
/* reg_sfd_mac_system_port
458+
* Unique port identifier for the final destination of the packet.
459+
* Access: RO
460+
*/
461+
MLXSW_ITEM32_INDEXED(reg, sfn, mac_system_port, MLXSW_REG_SFN_BASE_LEN, 0, 16,
462+
MLXSW_REG_SFN_REC_LEN, 0x0C, false);
463+
464+
static inline void mlxsw_reg_sfn_mac_unpack(char *payload, int rec_index,
465+
char *mac, u16 *p_vid,
466+
u8 *p_local_port)
467+
{
468+
mlxsw_reg_sfn_rec_mac_memcpy_from(payload, rec_index, mac);
469+
*p_vid = mlxsw_reg_sfn_mac_fid_get(payload, rec_index);
470+
*p_local_port = mlxsw_reg_sfn_mac_system_port_get(payload, rec_index);
471+
}
472+
374473
/* SPMS - Switch Port MSTP/RSTP State Register
375474
* -------------------------------------------
376475
* Configures the spanning tree state of a physical port.
@@ -1467,6 +1566,8 @@ static inline const char *mlxsw_reg_id_str(u16 reg_id)
14671566
return "SSPR";
14681567
case MLXSW_REG_SFD_ID:
14691568
return "SFD";
1569+
case MLXSW_REG_SFN_ID:
1570+
return "SFN";
14701571
case MLXSW_REG_SPMS_ID:
14711572
return "SPMS";
14721573
case MLXSW_REG_SFGC_ID:

0 commit comments

Comments
 (0)