iPXE
Functions
mlx_mtu.c File Reference
#include "mlx_mtu.h"
#include "../../include/public/mlx_memory.h"
#include "../../include/public/mlx_bail.h"

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER)
 
mlx_status mlx_get_max_mtu (IN mlx_utils *utils, IN mlx_uint8 port_num, OUT mlx_uint32 *max_mtu)
 
mlx_status mlx_set_admin_mtu (IN mlx_utils *utils, IN mlx_uint8 port_num, IN mlx_uint32 admin_mtu)
 

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER  )

◆ mlx_get_max_mtu()

mlx_status mlx_get_max_mtu ( IN mlx_utils utils,
IN mlx_uint8  port_num,
OUT mlx_uint32 max_mtu 
)

Definition at line 27 of file mlx_mtu.c.

32 {
34  struct mlx_mtu mtu;
35  mlx_uint32 reg_status;
36  *max_mtu = 0;
37 
38  if (utils == NULL) {
40  goto bad_param;
41  }
42 
43  mlx_memory_set(utils, &mtu, 0, sizeof(mtu));
44 
45  mtu.local_port = port_num;
46 
48  sizeof(mtu), &reg_status);
49  MLX_CHECK_STATUS(utils, status, reg_err, "mlx_reg_access failed ");
50  if (reg_status != 0) {
51  MLX_DEBUG_ERROR(utils,"mlx_reg_access failed with status = %d\n", reg_status);
53  goto reg_err;
54  }
55  // Return data in bits
56  *max_mtu = mtu.max_mtu * BYTE_TO_BIT;
57 reg_err:
58 bad_param:
59  return status;
60 }
#define BYTE_TO_BIT
Definition: mlx_mtu.h:28
#define MLX_INVALID_PARAMETER
#define REG_ID_PMTU
uint8_t status
Status.
Definition: ena.h:16
uint32_t mlx_uint32
mlx_status mlx_memory_set(IN mlx_utils *utils, IN mlx_void *block, IN mlx_int32 value, IN mlx_size size)
Definition: mlx_memory.c:171
#define MLX_SUCCESS
#define MLX_FAILED
__be16 port_num
Definition: CIB_PRM.h:31
mlx_uint32 max_mtu
Definition: mlx_mtu.h:36
uint32_t mtu
Maximum MTU.
Definition: ena.h:28
#define MLX_DEBUG_ERROR(...)
Definition: mlx_logging.h:29
int mlx_status
mlx_status mlx_reg_access(IN mlx_utils *utils, IN mlx_uint16 reg_id, IN REG_ACCESS_OPT reg_opt, IN OUT mlx_void *reg_data, IN mlx_size reg_size, OUT mlx_uint32 *reg_status)
#define MLX_CHECK_STATUS(id, status, label, message)
Definition: mlx_bail.h:37
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

References BYTE_TO_BIT, mlx_mtu::max_mtu, MLX_CHECK_STATUS, MLX_DEBUG_ERROR, MLX_FAILED, MLX_INVALID_PARAMETER, mlx_memory_set(), mlx_reg_access(), MLX_SUCCESS, mtu, NULL, port_num, REG_ACCESS_READ, REG_ID_PMTU, and status.

◆ mlx_set_admin_mtu()

mlx_status mlx_set_admin_mtu ( IN mlx_utils utils,
IN mlx_uint8  port_num,
IN mlx_uint32  admin_mtu 
)

Definition at line 63 of file mlx_mtu.c.

68 {
70  struct mlx_mtu mtu;
71  mlx_uint32 reg_status;
72 
73  if (utils == NULL) {
75  goto bad_param;
76  }
77 
78  mlx_memory_set(utils, &mtu, 0, sizeof(mtu));
79 
80  mtu.local_port = port_num;
81  mtu.admin_mtu = admin_mtu;
82 
84  sizeof(mtu), &reg_status);
85  MLX_CHECK_STATUS(utils, status, reg_err, "mlx_reg_access failed ");
86  if (reg_status != 0) {
87  MLX_DEBUG_ERROR(utils,"mlx_reg_access failed with status = %d\n", reg_status);
89  goto reg_err;
90  }
91 reg_err:
92 bad_param:
93  return status;
94 }
#define MLX_INVALID_PARAMETER
#define REG_ID_PMTU
mlx_uint32 admin_mtu
Definition: mlx_mtu.h:39
uint8_t status
Status.
Definition: ena.h:16
uint32_t mlx_uint32
mlx_status mlx_memory_set(IN mlx_utils *utils, IN mlx_void *block, IN mlx_int32 value, IN mlx_size size)
Definition: mlx_memory.c:171
#define MLX_SUCCESS
#define MLX_FAILED
__be16 port_num
Definition: CIB_PRM.h:31
uint32_t mtu
Maximum MTU.
Definition: ena.h:28
#define MLX_DEBUG_ERROR(...)
Definition: mlx_logging.h:29
int mlx_status
mlx_status mlx_reg_access(IN mlx_utils *utils, IN mlx_uint16 reg_id, IN REG_ACCESS_OPT reg_opt, IN OUT mlx_void *reg_data, IN mlx_size reg_size, OUT mlx_uint32 *reg_status)
#define MLX_CHECK_STATUS(id, status, label, message)
Definition: mlx_bail.h:37
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

References mlx_mtu::admin_mtu, MLX_CHECK_STATUS, MLX_DEBUG_ERROR, MLX_FAILED, MLX_INVALID_PARAMETER, mlx_memory_set(), mlx_reg_access(), MLX_SUCCESS, mtu, NULL, port_num, REG_ACCESS_WRITE, REG_ID_PMTU, and status.

Referenced by flexboot_nodnic_probe().