Skip to content

Commit

Permalink
tests: Simplify requires_reformat_support function
Browse files Browse the repository at this point in the history
Replace the current query cap methodology with a simpler and more
readable implementation.

Signed-off-by: Shachar Kagan <[email protected]>
Signed-off-by: Edward Srouji <[email protected]>
  • Loading branch information
ShacharKagan authored and EdwardSro committed Aug 1, 2023
1 parent d1c71a2 commit 2d31ff9
Showing 1 changed file with 5 additions and 28 deletions.
33 changes: 5 additions & 28 deletions tests/test_mlx5_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,41 +23,18 @@

MAX_MATCH_PARAM_SIZE = 0x180

MLX5_CMD_OP_QUERY_HCA_CAP = 0x100
MLX5_CMD_MOD_NIC_FLOW_TABLE_CAP = 0x7
MLX5_CMD_OP_QUERY_HCA_CAP_OUT_LEN = 0x1010


@u.skip_unsupported
def requires_reformat_support(func):
def func_wrapper(instance):
try:
ctx = Mlx5Context(Mlx5DVContextAttr(), instance.dev_name)
except PyverbsUserError as ex:
raise unittest.SkipTest(f'Could not open mlx5 context ({ex})')
except PyverbsRDMAError:
raise unittest.SkipTest('Opening mlx5 context is not supported')
# Query NIC Flow Table capabilities
cmd_in = struct.pack('!HIH8s', MLX5_CMD_OP_QUERY_HCA_CAP, 0,
MLX5_CMD_MOD_NIC_FLOW_TABLE_CAP << 1 | 0x1,
bytes(8))
try:
cmd_out = Mlx5Context.devx_general_cmd(ctx, cmd_in,
MLX5_CMD_OP_QUERY_HCA_CAP_OUT_LEN)
except PyverbsRDMAError as ex:
if ex.error_code in [errno.EOPNOTSUPP, errno.EPROTONOSUPPORT]:
raise unittest.SkipTest('DevX general command is not supported')
raise ex
cmd_view = memoryview(cmd_out)
status = cmd_view[0]
if status:
raise PyverbsRDMAError('Query NIC Flow Table CAPs failed with status'
f' ({status})')
nic_tbl_caps = u.query_nic_flow_table_caps(instance)
# Verify that both NIC RX and TX support reformat actions by checking
# the following PRM fields: encap_general_header,
# log_max_packet_reformat, and reformat (for both RX and TX).
if not (cmd_view[20] & 0x80 and cmd_view[21] & 0x1f and
cmd_view[80] & 0x1 and cmd_view[272] & 0x1):
if not(nic_tbl_caps.encap_general_header and
nic_tbl_caps.log_max_packet_reformat_context and
nic_tbl_caps.flow_table_properties_nic_receive.reformat and
nic_tbl_caps.flow_table_properties_nic_transmit.reformat):
raise unittest.SkipTest('NIC flow table does not support reformat')
return func(instance)
return func_wrapper
Expand Down

0 comments on commit 2d31ff9

Please sign in to comment.