From: stsp Date: Fri, 9 Jul 2021 10:42:35 +0000 (+0000) Subject: Simplify code supporting the new iwm(4) time quota firmware command. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=37d7c3874cf874e6140a0d3b4f7adade938a1314;p=openbsd Simplify code supporting the new iwm(4) time quota firmware command. There was no real need to use a separate function for this. --- diff --git a/sys/dev/pci/if_iwm.c b/sys/dev/pci/if_iwm.c index e760d1a2068..1c03b37e63a 100644 --- a/sys/dev/pci/if_iwm.c +++ b/sys/dev/pci/if_iwm.c @@ -1,4 +1,4 @@ -/* $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 @@ -465,7 +465,6 @@ void iwm_mac_ctxt_cmd_common(struct iwm_softc *, struct iwm_node *, 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 *); @@ -7883,7 +7882,7 @@ iwm_mac_ctxt_cmd(struct iwm_softc *sc, struct iwm_node *in, uint32_t action, } 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; @@ -7940,70 +7939,21 @@ iwm_update_quotas_v1(struct iwm_softc *sc, struct iwm_node *in, int running) /* 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); }