-/* $OpenBSD: if_iwm.c,v 1.343 2021/07/08 17:14:08 stsp Exp $ */
+/* $OpenBSD: if_iwm.c,v 1.344 2021/07/09 10:42:35 stsp Exp $ */
/*
* Copyright (c) 2014, 2016 genua gmbh <info@genua.de>
void iwm_mac_ctxt_cmd_fill_sta(struct iwm_softc *, struct iwm_node *,
struct iwm_mac_data_sta *, int);
int iwm_mac_ctxt_cmd(struct iwm_softc *, struct iwm_node *, uint32_t, int);
-int iwm_update_quotas_v1(struct iwm_softc *, struct iwm_node *, int);
int iwm_update_quotas(struct iwm_softc *, struct iwm_node *, int);
void iwm_add_task(struct iwm_softc *, struct taskq *, struct task *);
void iwm_del_task(struct iwm_softc *, struct taskq *, struct task *);
}
int
-iwm_update_quotas_v1(struct iwm_softc *sc, struct iwm_node *in, int running)
+iwm_update_quotas(struct iwm_softc *sc, struct iwm_node *in, int running)
{
struct iwm_time_quota_cmd_v1 cmd;
int i, idx, num_active_macs, quota, quota_rem;
/* Give the remainder of the session to the first binding */
cmd.quotas[0].quota = htole32(le32toh(cmd.quotas[0].quota) + quota_rem);
- return iwm_send_cmd_pdu(sc, IWM_TIME_QUOTA_CMD, 0, sizeof(cmd), &cmd);
-}
-
-int
-iwm_update_quotas(struct iwm_softc *sc, struct iwm_node *in, int running)
-{
- struct iwm_time_quota_cmd cmd;
- int i, idx, num_active_macs, quota, quota_rem;
- int colors[IWM_MAX_BINDINGS] = { -1, -1, -1, -1, };
- int n_ifs[IWM_MAX_BINDINGS] = {0, };
- uint16_t id;
-
- if (!isset(sc->sc_ucode_api, IWM_UCODE_TLV_API_QUOTA_LOW_LATENCY))
- return iwm_update_quotas_v1(sc, in, running);
-
- memset(&cmd, 0, sizeof(cmd));
-
- /* currently, PHY ID == binding ID */
- if (in && in->in_phyctxt) {
- id = in->in_phyctxt->id;
- KASSERT(id < IWM_MAX_BINDINGS);
- colors[id] = in->in_phyctxt->color;
- if (running)
- n_ifs[id] = 1;
- }
-
- /*
- * The FW's scheduling session consists of
- * IWM_MAX_QUOTA fragments. Divide these fragments
- * equally between all the bindings that require quota
- */
- num_active_macs = 0;
- for (i = 0; i < IWM_MAX_BINDINGS; i++) {
- cmd.quotas[i].id_and_color = htole32(IWM_FW_CTXT_INVALID);
- num_active_macs += n_ifs[i];
- }
-
- quota = 0;
- quota_rem = 0;
- if (num_active_macs) {
- quota = IWM_MAX_QUOTA / num_active_macs;
- quota_rem = IWM_MAX_QUOTA % num_active_macs;
- }
+ if (isset(sc->sc_ucode_api, IWM_UCODE_TLV_API_QUOTA_LOW_LATENCY)) {
+ struct iwm_time_quota_cmd cmd_v2;
- for (idx = 0, i = 0; i < IWM_MAX_BINDINGS; i++) {
- if (colors[i] < 0)
- continue;
-
- cmd.quotas[idx].id_and_color =
- htole32(IWM_FW_CMD_ID_AND_COLOR(i, colors[i]));
-
- if (n_ifs[i] <= 0) {
- cmd.quotas[idx].quota = htole32(0);
- cmd.quotas[idx].max_duration = htole32(0);
- } else {
- cmd.quotas[idx].quota = htole32(quota * n_ifs[i]);
- cmd.quotas[idx].max_duration = htole32(0);
+ memset(&cmd_v2, 0, sizeof(cmd_v2));
+ for (i = 0; i < IWM_MAX_BINDINGS; i++) {
+ cmd_v2.quotas[i].id_and_color =
+ cmd.quotas[i].id_and_color;
+ cmd_v2.quotas[i].quota = cmd.quotas[i].quota;
+ cmd_v2.quotas[i].max_duration =
+ cmd.quotas[i].max_duration;
}
- idx++;
+ return iwm_send_cmd_pdu(sc, IWM_TIME_QUOTA_CMD, 0,
+ sizeof(cmd_v2), &cmd_v2);
}
- /* Give the remainder of the session to the first binding */
- cmd.quotas[0].quota = htole32(le32toh(cmd.quotas[0].quota) + quota_rem);
-
return iwm_send_cmd_pdu(sc, IWM_TIME_QUOTA_CMD, 0, sizeof(cmd), &cmd);
}