Lines Matching refs:hdroom

303 void mlxsw_sp_hdroom_prios_reset_buf_idx(struct mlxsw_sp_hdroom *hdroom)  in mlxsw_sp_hdroom_prios_reset_buf_idx()  argument
308 switch (hdroom->mode) { in mlxsw_sp_hdroom_prios_reset_buf_idx()
310 hdroom->prios.prio[prio].buf_idx = hdroom->prios.prio[prio].ets_buf_idx; in mlxsw_sp_hdroom_prios_reset_buf_idx()
313 hdroom->prios.prio[prio].buf_idx = hdroom->prios.prio[prio].set_buf_idx; in mlxsw_sp_hdroom_prios_reset_buf_idx()
319 void mlxsw_sp_hdroom_bufs_reset_lossiness(struct mlxsw_sp_hdroom *hdroom) in mlxsw_sp_hdroom_bufs_reset_lossiness() argument
325 hdroom->bufs.buf[i].lossy = true; in mlxsw_sp_hdroom_bufs_reset_lossiness()
328 if (!hdroom->prios.prio[prio].lossy) in mlxsw_sp_hdroom_bufs_reset_lossiness()
329 hdroom->bufs.buf[hdroom->prios.prio[prio].buf_idx].lossy = false; in mlxsw_sp_hdroom_bufs_reset_lossiness()
348 const struct mlxsw_sp_hdroom *hdroom) in mlxsw_sp_hdroom_buf_delay_get() argument
352 delay_cells = mlxsw_sp_bytes_cells(mlxsw_sp, hdroom->delay_bytes); in mlxsw_sp_hdroom_buf_delay_get()
362 return 2 * delay_cells + mlxsw_sp_bytes_cells(mlxsw_sp, hdroom->mtu); in mlxsw_sp_hdroom_buf_delay_get()
372 static bool mlxsw_sp_hdroom_buf_is_used(const struct mlxsw_sp_hdroom *hdroom, int buf) in mlxsw_sp_hdroom_buf_is_used() argument
377 if (hdroom->prios.prio[prio].buf_idx == buf) in mlxsw_sp_hdroom_buf_is_used()
384 struct mlxsw_sp_hdroom *hdroom) in mlxsw_sp_hdroom_bufs_reset_sizes() argument
394 hdroom->int_buf.reserve_cells = reserve_cells; in mlxsw_sp_hdroom_bufs_reset_sizes()
396 if (hdroom->int_buf.enable) in mlxsw_sp_hdroom_bufs_reset_sizes()
397 hdroom->int_buf.size_cells = reserve_cells; in mlxsw_sp_hdroom_bufs_reset_sizes()
399 hdroom->int_buf.size_cells = 0; in mlxsw_sp_hdroom_bufs_reset_sizes()
403 struct mlxsw_sp_hdroom_buf *buf = &hdroom->bufs.buf[i]; in mlxsw_sp_hdroom_bufs_reset_sizes()
407 if (!mlxsw_sp_hdroom_buf_is_used(hdroom, i)) { in mlxsw_sp_hdroom_bufs_reset_sizes()
411 thres_cells = mlxsw_sp_hdroom_buf_threshold_get(mlxsw_sp, hdroom->mtu); in mlxsw_sp_hdroom_bufs_reset_sizes()
414 thres_cells = mlxsw_sp_hdroom_buf_threshold_get(mlxsw_sp, hdroom->mtu); in mlxsw_sp_hdroom_bufs_reset_sizes()
415 delay_cells = mlxsw_sp_hdroom_buf_delay_get(mlxsw_sp, hdroom); in mlxsw_sp_hdroom_bufs_reset_sizes()
422 if (hdroom->mode == MLXSW_SP_HDROOM_MODE_DCB) { in mlxsw_sp_hdroom_bufs_reset_sizes()
436 const struct mlxsw_sp_hdroom *hdroom, bool force) in mlxsw_sp_hdroom_configure_buffers() argument
444 dirty = memcmp(&mlxsw_sp_port->hdroom->bufs, &hdroom->bufs, sizeof(hdroom->bufs)); in mlxsw_sp_hdroom_configure_buffers()
450 const struct mlxsw_sp_hdroom_buf *buf = &hdroom->bufs.buf[i]; in mlxsw_sp_hdroom_configure_buffers()
463 mlxsw_sp_port->hdroom->bufs = hdroom->bufs; in mlxsw_sp_hdroom_configure_buffers()
468 const struct mlxsw_sp_hdroom *hdroom, bool force) in mlxsw_sp_hdroom_configure_priomap() argument
475 dirty = memcmp(&mlxsw_sp_port->hdroom->prios, &hdroom->prios, sizeof(hdroom->prios)); in mlxsw_sp_hdroom_configure_priomap()
481 mlxsw_reg_pptb_prio_to_buff_pack(pptb_pl, prio, hdroom->prios.prio[prio].buf_idx); in mlxsw_sp_hdroom_configure_priomap()
487 mlxsw_sp_port->hdroom->prios = hdroom->prios; in mlxsw_sp_hdroom_configure_priomap()
492 const struct mlxsw_sp_hdroom *hdroom, bool force) in mlxsw_sp_hdroom_configure_int_buf() argument
498 dirty = memcmp(&mlxsw_sp_port->hdroom->int_buf, &hdroom->int_buf, sizeof(hdroom->int_buf)); in mlxsw_sp_hdroom_configure_int_buf()
502 mlxsw_reg_sbib_pack(sbib_pl, mlxsw_sp_port->local_port, hdroom->int_buf.size_cells); in mlxsw_sp_hdroom_configure_int_buf()
507 mlxsw_sp_port->hdroom->int_buf = hdroom->int_buf; in mlxsw_sp_hdroom_configure_int_buf()
512 const struct mlxsw_sp_hdroom *hdroom) in mlxsw_sp_hdroom_bufs_fit() argument
518 taken_headroom_cells += hdroom->bufs.buf[i].size_cells; in mlxsw_sp_hdroom_bufs_fit()
520 taken_headroom_cells += hdroom->int_buf.reserve_cells; in mlxsw_sp_hdroom_bufs_fit()
525 const struct mlxsw_sp_hdroom *hdroom, bool force) in __mlxsw_sp_hdroom_configure() argument
540 orig_hdroom = *mlxsw_sp_port->hdroom; in __mlxsw_sp_hdroom_configure()
543 if (hdroom->bufs.buf[i].size_cells) in __mlxsw_sp_hdroom_configure()
544 tmp_hdroom.bufs.buf[i] = hdroom->bufs.buf[i]; in __mlxsw_sp_hdroom_configure()
548 !mlxsw_sp_hdroom_bufs_fit(mlxsw_sp_port->mlxsw_sp, hdroom)) in __mlxsw_sp_hdroom_configure()
555 err = mlxsw_sp_hdroom_configure_priomap(mlxsw_sp_port, hdroom, force); in __mlxsw_sp_hdroom_configure()
559 err = mlxsw_sp_hdroom_configure_buffers(mlxsw_sp_port, hdroom, false); in __mlxsw_sp_hdroom_configure()
563 err = mlxsw_sp_hdroom_configure_int_buf(mlxsw_sp_port, hdroom, false); in __mlxsw_sp_hdroom_configure()
567 *mlxsw_sp_port->hdroom = *hdroom; in __mlxsw_sp_hdroom_configure()
580 const struct mlxsw_sp_hdroom *hdroom) in mlxsw_sp_hdroom_configure() argument
582 return __mlxsw_sp_hdroom_configure(mlxsw_sp_port, hdroom, false); in mlxsw_sp_hdroom_configure()
588 struct mlxsw_sp_hdroom hdroom = {}; in mlxsw_sp_port_headroom_init() local
592 hdroom.mtu = mlxsw_sp_port->dev->mtu; in mlxsw_sp_port_headroom_init()
593 hdroom.mode = MLXSW_SP_HDROOM_MODE_DCB; in mlxsw_sp_port_headroom_init()
595 hdroom.prios.prio[prio].lossy = true; in mlxsw_sp_port_headroom_init()
597 mlxsw_sp_hdroom_bufs_reset_lossiness(&hdroom); in mlxsw_sp_port_headroom_init()
598 mlxsw_sp_hdroom_bufs_reset_sizes(mlxsw_sp_port, &hdroom); in mlxsw_sp_port_headroom_init()
602 hdroom.bufs.buf[9].size_cells = mlxsw_sp_bytes_cells(mlxsw_sp, size9); in mlxsw_sp_port_headroom_init()
604 return __mlxsw_sp_hdroom_configure(mlxsw_sp_port, &hdroom, true); in mlxsw_sp_port_headroom_init()
1300 mlxsw_sp_port->hdroom = kzalloc(sizeof(*mlxsw_sp_port->hdroom), GFP_KERNEL); in mlxsw_sp_port_buffers_init()
1301 if (!mlxsw_sp_port->hdroom) in mlxsw_sp_port_buffers_init()
1303 mlxsw_sp_port->hdroom->mtu = mlxsw_sp_port->dev->mtu; in mlxsw_sp_port_buffers_init()
1319 kfree(mlxsw_sp_port->hdroom); in mlxsw_sp_port_buffers_init()
1325 kfree(mlxsw_sp_port->hdroom); in mlxsw_sp_port_buffers_fini()