Lines Matching +full:per +full:- +full:port

1 // SPDX-License-Identifier: (GPL-2.0 OR MIT)
2 /* Copyright 2020-2021 NXP
8 * Resource 0: Memory tracked per source port
9 * Resource 1: Frame references tracked per source port
10 * Resource 2: Memory tracked per destination port
11 * Resource 3: Frame references tracked per destination port
22 * Q_RSRV: reservation per QoS class per port
23 * PRIO_SHR: sharing watermark per QoS class across all ports
24 * P_RSRV: reservation per port
25 * COL_SHR: sharing watermark per color (drop precedence) across all ports
33 * ----------------------
35 * For setting up the reserved areas, egress watermarks exist per port and per
40 * | per QoS class
42 * | | | per egress port
47 #define BUF_Q_RSRV_E(port, prio) \ argument
48 (BUF_xxxx_E + xxx_Q_RSRV_x + OCELOT_NUM_TC * (port) + (prio))
51 * | for all port's traffic classes
53 * | | | per egress port
58 #define BUF_P_RSRV_E(port) \ argument
59 (BUF_xxxx_E + xxx_P_RSRV_x + (port))
62 * | per QoS class
64 * | | | per ingress port
69 #define BUF_Q_RSRV_I(port, prio) \ argument
70 (BUF_xxxx_I + xxx_Q_RSRV_x + OCELOT_NUM_TC * (port) + (prio))
73 * | for all port's traffic classes
75 * | | | per ingress port
80 #define BUF_P_RSRV_I(port) \ argument
81 (BUF_xxxx_I + xxx_P_RSRV_x + (port))
84 * | per QoS class
86 * | | | per egress port
91 #define REF_Q_RSRV_E(port, prio) \ argument
92 (REF_xxxx_E + xxx_Q_RSRV_x + OCELOT_NUM_TC * (port) + (prio))
95 * | for all port's traffic classes
97 * | | | per egress port
102 #define REF_P_RSRV_E(port) \ argument
103 (REF_xxxx_E + xxx_P_RSRV_x + (port))
106 * | per QoS class
108 * | | | per ingress port
113 #define REF_Q_RSRV_I(port, prio) \ argument
114 (REF_xxxx_I + xxx_Q_RSRV_x + OCELOT_NUM_TC * (port) + (prio))
117 * | for all port's traffic classes
119 * | | | per ingress port
124 #define REF_P_RSRV_I(port) \ argument
125 (REF_xxxx_I + xxx_P_RSRV_x + (port))
128 * ------------------
134 * | per QoS class
145 * | per color (drop precedence level)
153 (BUF_xxxx_E + xxx_COL_SHR_x + (1 - (dp)))
156 * | per QoS class
167 * | per color (drop precedence level)
175 (BUF_xxxx_I + xxx_COL_SHR_x + (1 - (dp)))
178 * | per QoS class
189 * | per color (drop precedence level)
197 (REF_xxxx_E + xxx_COL_SHR_x + (1 - (dp)))
200 * | per QoS class
211 * | per color (drop precedence level)
219 (REF_xxxx_I + xxx_COL_SHR_x + (1 - (dp)))
225 return ocelot->ops->wm_dec(wm); in ocelot_wm_read()
230 u32 wm = ocelot->ops->wm_enc(val); in ocelot_wm_write()
240 return ocelot->ops->wm_stat(res_stat, inuse, maxuse); in ocelot_wm_status()
249 * precedence 0. The user can still explicitly request reservations per port
250 * and per port-tc through devlink-sb.
253 int port) in ocelot_disable_reservation_watermarks() argument
258 ocelot_wm_write(ocelot, BUF_Q_RSRV_I(port, prio), 0); in ocelot_disable_reservation_watermarks()
259 ocelot_wm_write(ocelot, BUF_Q_RSRV_E(port, prio), 0); in ocelot_disable_reservation_watermarks()
260 ocelot_wm_write(ocelot, REF_Q_RSRV_I(port, prio), 0); in ocelot_disable_reservation_watermarks()
261 ocelot_wm_write(ocelot, REF_Q_RSRV_E(port, prio), 0); in ocelot_disable_reservation_watermarks()
264 ocelot_wm_write(ocelot, BUF_P_RSRV_I(port), 0); in ocelot_disable_reservation_watermarks()
265 ocelot_wm_write(ocelot, BUF_P_RSRV_E(port), 0); in ocelot_disable_reservation_watermarks()
266 ocelot_wm_write(ocelot, REF_P_RSRV_I(port), 0); in ocelot_disable_reservation_watermarks()
267 ocelot_wm_write(ocelot, REF_P_RSRV_E(port), 0); in ocelot_disable_reservation_watermarks()
274 * The switch has 10 sharing watermarks per lookup: 8 per traffic class and 2
275 * per color (drop precedence).
278 * (a) all 8 per-TC sharing watermarks to the max
279 * (b) all 2 per-color sharing watermarks to the max
281 * (a) all 8 per-TC sharing watermarks to "max / 8"
282 * (b) all 2 per-color sharing watermarks to "max / 2"
283 * So for Linux, let's just disable the sharing watermarks per traffic class
287 * the port and port-TC reservations are not exceeded.
304 int port, prio; in ocelot_get_buf_rsrv() local
309 for (port = 0; port <= ocelot->num_phys_ports; port++) { in ocelot_get_buf_rsrv()
312 BUF_Q_RSRV_I(port, prio)); in ocelot_get_buf_rsrv()
314 BUF_Q_RSRV_E(port, prio)); in ocelot_get_buf_rsrv()
317 *buf_rsrv_i += ocelot_wm_read(ocelot, BUF_P_RSRV_I(port)); in ocelot_get_buf_rsrv()
318 *buf_rsrv_e += ocelot_wm_read(ocelot, BUF_P_RSRV_E(port)); in ocelot_get_buf_rsrv()
328 int port, prio; in ocelot_get_ref_rsrv() local
333 for (port = 0; port <= ocelot->num_phys_ports; port++) { in ocelot_get_ref_rsrv()
336 REF_Q_RSRV_I(port, prio)); in ocelot_get_ref_rsrv()
338 REF_Q_RSRV_E(port, prio)); in ocelot_get_ref_rsrv()
341 *ref_rsrv_i += ocelot_wm_read(ocelot, REF_P_RSRV_I(port)); in ocelot_get_ref_rsrv()
342 *ref_rsrv_e += ocelot_wm_read(ocelot, REF_P_RSRV_E(port)); in ocelot_get_ref_rsrv()
359 buf_shr_i = ocelot->pool_size[OCELOT_SB_BUF][OCELOT_SB_POOL_ING] - in ocelot_setup_sharing_watermarks()
361 buf_shr_e = ocelot->pool_size[OCELOT_SB_BUF][OCELOT_SB_POOL_EGR] - in ocelot_setup_sharing_watermarks()
363 ref_shr_i = ocelot->pool_size[OCELOT_SB_REF][OCELOT_SB_POOL_ING] - in ocelot_setup_sharing_watermarks()
365 ref_shr_e = ocelot->pool_size[OCELOT_SB_REF][OCELOT_SB_POOL_EGR] - in ocelot_setup_sharing_watermarks()
391 if (buf_rsrv_i > ocelot->pool_size[OCELOT_SB_BUF][OCELOT_SB_POOL_ING]) { in ocelot_watermark_validate()
394 return -ERANGE; in ocelot_watermark_validate()
396 if (buf_rsrv_e > ocelot->pool_size[OCELOT_SB_BUF][OCELOT_SB_POOL_EGR]) { in ocelot_watermark_validate()
399 return -ERANGE; in ocelot_watermark_validate()
401 if (ref_rsrv_i > ocelot->pool_size[OCELOT_SB_REF][OCELOT_SB_POOL_ING]) { in ocelot_watermark_validate()
404 return -ERANGE; in ocelot_watermark_validate()
406 if (ref_rsrv_e > ocelot->pool_size[OCELOT_SB_REF][OCELOT_SB_POOL_EGR]) { in ocelot_watermark_validate()
409 return -ERANGE; in ocelot_watermark_validate()
420 * +--------------------+--------------------+--------------------+
428 *(src port, prio) -+ (dst port, prio) -+ (src port, prio) -+ (dst port, prio) -+
433 * (src port) ----+ (dst port) ----+ (src port) ----+ (dst port) -----+
438 * (prio) ------+ (prio) ------+ (prio) ------+ (prio) -------+
443 * (dp) -------+ (dp) -------+ (dp) -------+ (dp) --------+
450 * +-----+----+ +-----+----+ +-----+----+ +-----+-----+
452 * +-------> OR <-------+ +-------> OR <-------+
455 * +----------------> AND <-----------------+
460 * We are modeling each of the 4 parallel lookups as a devlink-sb pool.
464 * The following watermarks are controlled explicitly through devlink-sb:
467 * The following watermarks are controlled implicitly through devlink-sb:
478 int all_tcs = GENMASK(OCELOT_NUM_TC - 1, 0); in ocelot_watermark_init()
479 int port; in ocelot_watermark_init() local
483 for (port = 0; port <= ocelot->num_phys_ports; port++) in ocelot_watermark_init()
484 ocelot_disable_reservation_watermarks(ocelot, port); in ocelot_watermark_init()
492 * Bit 7-0: Value to be multiplied with unit
541 return -ENODEV; in ocelot_sb_pool_get()
543 return -ENODEV; in ocelot_sb_pool_get()
546 pool_info->size = ocelot->pool_size[sb_index][pool_index]; in ocelot_sb_pool_get()
548 pool_info->pool_type = DEVLINK_SB_POOL_TYPE_INGRESS; in ocelot_sb_pool_get()
550 pool_info->pool_type = DEVLINK_SB_POOL_TYPE_EGRESS; in ocelot_sb_pool_get()
558 * the values for the port and port-tc reservations, is written into the
572 return -ENODEV; in ocelot_sb_pool_set()
577 return -ENODEV; in ocelot_sb_pool_set()
582 return -EOPNOTSUPP; in ocelot_sb_pool_set()
585 old_pool_size = ocelot->pool_size[sb_index][pool_index]; in ocelot_sb_pool_set()
586 ocelot->pool_size[sb_index][pool_index] = size; in ocelot_sb_pool_set()
590 ocelot->pool_size[sb_index][pool_index] = old_pool_size; in ocelot_sb_pool_set()
601 int ocelot_sb_port_pool_get(struct ocelot *ocelot, int port, in ocelot_sb_port_pool_get() argument
610 wm_index = BUF_P_RSRV_I(port); in ocelot_sb_port_pool_get()
612 wm_index = BUF_P_RSRV_E(port); in ocelot_sb_port_pool_get()
616 wm_index = REF_P_RSRV_I(port); in ocelot_sb_port_pool_get()
618 wm_index = REF_P_RSRV_E(port); in ocelot_sb_port_pool_get()
621 return -ENODEV; in ocelot_sb_port_pool_get()
631 /* This configures the P_RSRV per-port reserved resource watermark */
632 int ocelot_sb_port_pool_set(struct ocelot *ocelot, int port, in ocelot_sb_port_pool_set() argument
642 wm_index = BUF_P_RSRV_I(port); in ocelot_sb_port_pool_set()
644 wm_index = BUF_P_RSRV_E(port); in ocelot_sb_port_pool_set()
648 wm_index = REF_P_RSRV_I(port); in ocelot_sb_port_pool_set()
650 wm_index = REF_P_RSRV_E(port); in ocelot_sb_port_pool_set()
654 return -ENODEV; in ocelot_sb_port_pool_set()
675 int ocelot_sb_tc_pool_bind_get(struct ocelot *ocelot, int port, in ocelot_sb_tc_pool_bind_get() argument
685 wm_index = BUF_Q_RSRV_I(port, tc_index); in ocelot_sb_tc_pool_bind_get()
687 wm_index = BUF_Q_RSRV_E(port, tc_index); in ocelot_sb_tc_pool_bind_get()
691 wm_index = REF_Q_RSRV_I(port, tc_index); in ocelot_sb_tc_pool_bind_get()
693 wm_index = REF_Q_RSRV_E(port, tc_index); in ocelot_sb_tc_pool_bind_get()
696 return -ENODEV; in ocelot_sb_tc_pool_bind_get()
711 /* This configures the Q_RSRV per-port-tc reserved resource watermark */
712 int ocelot_sb_tc_pool_bind_set(struct ocelot *ocelot, int port, in ocelot_sb_tc_pool_bind_set() argument
724 return -EINVAL; in ocelot_sb_tc_pool_bind_set()
727 return -EINVAL; in ocelot_sb_tc_pool_bind_set()
732 wm_index = BUF_Q_RSRV_I(port, tc_index); in ocelot_sb_tc_pool_bind_set()
734 wm_index = BUF_Q_RSRV_E(port, tc_index); in ocelot_sb_tc_pool_bind_set()
738 wm_index = REF_Q_RSRV_I(port, tc_index); in ocelot_sb_tc_pool_bind_set()
740 wm_index = REF_Q_RSRV_E(port, tc_index); in ocelot_sb_tc_pool_bind_set()
744 return -ENODEV; in ocelot_sb_tc_pool_bind_set()
778 int port, prio; in ocelot_sb_occ_max_clear() local
782 for (port = 0; port <= ocelot->num_phys_ports; port++) { in ocelot_sb_occ_max_clear()
784 ocelot_wm_status(ocelot, BUF_Q_RSRV_I(port, prio), in ocelot_sb_occ_max_clear()
786 ocelot_wm_status(ocelot, BUF_Q_RSRV_E(port, prio), in ocelot_sb_occ_max_clear()
789 ocelot_wm_status(ocelot, BUF_P_RSRV_I(port), in ocelot_sb_occ_max_clear()
791 ocelot_wm_status(ocelot, BUF_P_RSRV_E(port), in ocelot_sb_occ_max_clear()
796 for (port = 0; port <= ocelot->num_phys_ports; port++) { in ocelot_sb_occ_max_clear()
798 ocelot_wm_status(ocelot, REF_Q_RSRV_I(port, prio), in ocelot_sb_occ_max_clear()
800 ocelot_wm_status(ocelot, REF_Q_RSRV_E(port, prio), in ocelot_sb_occ_max_clear()
803 ocelot_wm_status(ocelot, REF_P_RSRV_I(port), in ocelot_sb_occ_max_clear()
805 ocelot_wm_status(ocelot, REF_P_RSRV_E(port), in ocelot_sb_occ_max_clear()
810 return -ENODEV; in ocelot_sb_occ_max_clear()
817 /* This retrieves the watermark occupancy for per-port P_RSRV watermarks */
818 int ocelot_sb_occ_port_pool_get(struct ocelot *ocelot, int port, in ocelot_sb_occ_port_pool_get() argument
827 wm_index = BUF_P_RSRV_I(port); in ocelot_sb_occ_port_pool_get()
829 wm_index = BUF_P_RSRV_E(port); in ocelot_sb_occ_port_pool_get()
833 wm_index = REF_P_RSRV_I(port); in ocelot_sb_occ_port_pool_get()
835 wm_index = REF_P_RSRV_E(port); in ocelot_sb_occ_port_pool_get()
838 return -ENODEV; in ocelot_sb_occ_port_pool_get()
849 /* This retrieves the watermark occupancy for per-port-tc Q_RSRV watermarks */
850 int ocelot_sb_occ_tc_port_bind_get(struct ocelot *ocelot, int port, in ocelot_sb_occ_tc_port_bind_get() argument
860 wm_index = BUF_Q_RSRV_I(port, tc_index); in ocelot_sb_occ_tc_port_bind_get()
862 wm_index = BUF_Q_RSRV_E(port, tc_index); in ocelot_sb_occ_tc_port_bind_get()
866 wm_index = REF_Q_RSRV_I(port, tc_index); in ocelot_sb_occ_tc_port_bind_get()
868 wm_index = REF_Q_RSRV_E(port, tc_index); in ocelot_sb_occ_tc_port_bind_get()
871 return -ENODEV; in ocelot_sb_occ_tc_port_bind_get()
886 err = devlink_sb_register(ocelot->devlink, OCELOT_SB_BUF, in ocelot_devlink_sb_register()
887 ocelot->packet_buffer_size, 1, 1, in ocelot_devlink_sb_register()
892 err = devlink_sb_register(ocelot->devlink, OCELOT_SB_REF, in ocelot_devlink_sb_register()
893 ocelot->num_frame_refs, 1, 1, in ocelot_devlink_sb_register()
896 devlink_sb_unregister(ocelot->devlink, OCELOT_SB_BUF); in ocelot_devlink_sb_register()
900 ocelot->pool_size[OCELOT_SB_BUF][OCELOT_SB_POOL_ING] = ocelot->packet_buffer_size; in ocelot_devlink_sb_register()
901 ocelot->pool_size[OCELOT_SB_BUF][OCELOT_SB_POOL_EGR] = ocelot->packet_buffer_size; in ocelot_devlink_sb_register()
902 ocelot->pool_size[OCELOT_SB_REF][OCELOT_SB_POOL_ING] = ocelot->num_frame_refs; in ocelot_devlink_sb_register()
903 ocelot->pool_size[OCELOT_SB_REF][OCELOT_SB_POOL_EGR] = ocelot->num_frame_refs; in ocelot_devlink_sb_register()
913 devlink_sb_unregister(ocelot->devlink, OCELOT_SB_BUF); in ocelot_devlink_sb_unregister()
914 devlink_sb_unregister(ocelot->devlink, OCELOT_SB_REF); in ocelot_devlink_sb_unregister()