Lines Matching +full:lo +full:- +full:en
1 // SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause)
19 struct enetc_hw *hw = &priv->si->hw; in enetc_sched_speed_set()
20 u32 old_speed = priv->speed; in enetc_sched_speed_set()
41 priv->speed = speed; in enetc_sched_speed_set()
50 struct enetc_hw *hw = &priv->si->hw; in enetc_setup_taprio()
63 if (admin_conf->num_entries > enetc_get_max_gcl_len(hw)) in enetc_setup_taprio()
64 return -EINVAL; in enetc_setup_taprio()
65 gcl_len = admin_conf->num_entries; in enetc_setup_taprio()
68 if (!admin_conf->enable) { in enetc_setup_taprio()
72 priv->active_offloads &= ~ENETC_F_QBV; in enetc_setup_taprio()
77 if (admin_conf->cycle_time > U32_MAX || in enetc_setup_taprio()
78 admin_conf->cycle_time_extension > U32_MAX) in enetc_setup_taprio()
79 return -EINVAL; in enetc_setup_taprio()
87 tmp = enetc_cbd_alloc_data_mem(priv->si, &cbd, data_size, in enetc_setup_taprio()
90 return -ENOMEM; in enetc_setup_taprio()
95 gcl_config->atc = 0xff; in enetc_setup_taprio()
96 gcl_config->acl_len = cpu_to_le16(gcl_len); in enetc_setup_taprio()
98 gcl_data->btl = cpu_to_le32(lower_32_bits(admin_conf->base_time)); in enetc_setup_taprio()
99 gcl_data->bth = cpu_to_le32(upper_32_bits(admin_conf->base_time)); in enetc_setup_taprio()
100 gcl_data->ct = cpu_to_le32(admin_conf->cycle_time); in enetc_setup_taprio()
101 gcl_data->cte = cpu_to_le32(admin_conf->cycle_time_extension); in enetc_setup_taprio()
107 temp_entry = &admin_conf->entries[i]; in enetc_setup_taprio()
109 temp_gce->gate = (u8)temp_entry->gate_mask; in enetc_setup_taprio()
110 temp_gce->period = cpu_to_le32(temp_entry->interval); in enetc_setup_taprio()
120 err = enetc_send_cmd(priv->si, &cbd); in enetc_setup_taprio()
124 enetc_cbd_free_data_mem(priv->si, data_size, tmp, &dma); in enetc_setup_taprio()
129 enetc_set_ptcmsdur(hw, admin_conf->max_sdu); in enetc_setup_taprio()
130 priv->active_offloads |= ENETC_F_QBV; in enetc_setup_taprio()
139 struct enetc_hw *hw = &priv->si->hw; in enetc_setup_tc_taprio()
145 for (i = 0; i < priv->num_tx_rings; i++) in enetc_setup_tc_taprio()
146 if (priv->tx_ring[i]->tsd_enable) in enetc_setup_tc_taprio()
147 return -EBUSY; in enetc_setup_tc_taprio()
149 for (i = 0; i < priv->num_tx_rings; i++) { in enetc_setup_tc_taprio()
150 tx_ring = priv->tx_ring[i]; in enetc_setup_tc_taprio()
151 tx_ring->prio = taprio->enable ? i : 0; in enetc_setup_tc_taprio()
152 enetc_set_bdr_prio(hw, tx_ring->index, tx_ring->prio); in enetc_setup_tc_taprio()
157 for (i = 0; i < priv->num_tx_rings; i++) { in enetc_setup_tc_taprio()
158 tx_ring = priv->tx_ring[i]; in enetc_setup_tc_taprio()
159 tx_ring->prio = taprio->enable ? 0 : i; in enetc_setup_tc_taprio()
160 enetc_set_bdr_prio(hw, tx_ring->index, tx_ring->prio); in enetc_setup_tc_taprio()
181 u32 port_transmit_rate = priv->speed; in enetc_setup_tc_cbs()
183 struct enetc_hw *hw = &priv->si->hw; in enetc_setup_tc_cbs()
187 u8 tc = cbs->queue; in enetc_setup_tc_cbs()
192 prio_top = netdev_get_prio_tc_map(ndev, tc_nums - 1); in enetc_setup_tc_cbs()
193 prio_next = netdev_get_prio_tc_map(ndev, tc_nums - 2); in enetc_setup_tc_cbs()
197 return -EOPNOTSUPP; in enetc_setup_tc_cbs()
199 if (!cbs->enable) { in enetc_setup_tc_cbs()
205 dev_err(&ndev->dev, in enetc_setup_tc_cbs()
208 return -EINVAL; in enetc_setup_tc_cbs()
217 if (cbs->idleslope - cbs->sendslope != port_transmit_rate * 1000L || in enetc_setup_tc_cbs()
218 cbs->idleslope < 0 || cbs->sendslope > 0) in enetc_setup_tc_cbs()
219 return -EOPNOTSUPP; in enetc_setup_tc_cbs()
221 port_frame_max_size = ndev->mtu + VLAN_ETH_HLEN + ETH_FCS_LEN; in enetc_setup_tc_cbs()
223 bw = cbs->idleslope / (port_transmit_rate * 10UL); in enetc_setup_tc_cbs()
230 dev_err(&ndev->dev, in enetc_setup_tc_cbs()
233 return -EINVAL; in enetc_setup_tc_cbs()
239 dev_err(&ndev->dev, in enetc_setup_tc_cbs()
241 return -EINVAL; in enetc_setup_tc_cbs()
250 * max_interference_size = M0 + Ma + Ra * M0 / (R0 - Ra) in enetc_setup_tc_cbs()
252 * - RA: idleSlope for AVB Class A in enetc_setup_tc_cbs()
253 * - R0: port transmit rate in enetc_setup_tc_cbs()
254 * - M0: maximum sized frame for the port in enetc_setup_tc_cbs()
255 * - MA: maximum sized frame for AVB Class A in enetc_setup_tc_cbs()
269 (u32)div_u64((u64)ra * m0, r0 - ra); in enetc_setup_tc_cbs()
298 struct enetc_hw *hw = &priv->si->hw; in enetc_setup_tc_txtime()
302 return -EOPNOTSUPP; in enetc_setup_tc_txtime()
304 tc = qopt->queue; in enetc_setup_tc_txtime()
306 if (tc < 0 || tc >= priv->num_tx_rings) in enetc_setup_tc_txtime()
307 return -EINVAL; in enetc_setup_tc_txtime()
311 return -EBUSY; in enetc_setup_tc_txtime()
313 priv->tx_ring[tc]->tsd_enable = qopt->enable; in enetc_setup_tc_txtime()
314 enetc_port_wr(hw, ENETC_PTCTSDR(tc), qopt->enable ? ENETC_TSDE : 0); in enetc_setup_tc_txtime()
332 #define ENETC_PSFP_WILDCARD -1
467 port = enetc_pf_to_port(priv->si->pdev); in enetc_streamid_hw_set()
469 return -EINVAL; in enetc_streamid_hw_set()
471 if (sid->index >= priv->psfp_cap.max_streamid) in enetc_streamid_hw_set()
472 return -EINVAL; in enetc_streamid_hw_set()
474 if (sid->filtertype != STREAMID_TYPE_NULL && in enetc_streamid_hw_set()
475 sid->filtertype != STREAMID_TYPE_SMAC) in enetc_streamid_hw_set()
476 return -EOPNOTSUPP; in enetc_streamid_hw_set()
479 cbd.index = cpu_to_le16((u16)sid->index); in enetc_streamid_hw_set()
484 tmp = enetc_cbd_alloc_data_mem(priv->si, &cbd, data_size, in enetc_streamid_hw_set()
487 return -ENOMEM; in enetc_streamid_hw_set()
489 eth_broadcast_addr(si_data->dmac); in enetc_streamid_hw_set()
490 si_data->vid_vidm_tg = (ENETC_CBDR_SID_VID_MASK in enetc_streamid_hw_set()
495 si_conf->iports = cpu_to_le32(1 << port); in enetc_streamid_hw_set()
496 si_conf->id_type = 1; in enetc_streamid_hw_set()
497 si_conf->oui[2] = 0x0; in enetc_streamid_hw_set()
498 si_conf->oui[1] = 0x80; in enetc_streamid_hw_set()
499 si_conf->oui[0] = 0xC2; in enetc_streamid_hw_set()
501 err = enetc_send_cmd(priv->si, &cbd); in enetc_streamid_hw_set()
511 si_conf->en = 0x80; in enetc_streamid_hw_set()
512 si_conf->stream_handle = cpu_to_le32(sid->handle); in enetc_streamid_hw_set()
513 si_conf->iports = cpu_to_le32(1 << port); in enetc_streamid_hw_set()
514 si_conf->id_type = sid->filtertype; in enetc_streamid_hw_set()
515 si_conf->oui[2] = 0x0; in enetc_streamid_hw_set()
516 si_conf->oui[1] = 0x80; in enetc_streamid_hw_set()
517 si_conf->oui[0] = 0xC2; in enetc_streamid_hw_set()
526 if (si_conf->id_type == STREAMID_TYPE_NULL) { in enetc_streamid_hw_set()
527 ether_addr_copy(si_data->dmac, sid->dst_mac); in enetc_streamid_hw_set()
528 si_data->vid_vidm_tg = (sid->vid & ENETC_CBDR_SID_VID_MASK) + in enetc_streamid_hw_set()
529 ((((u16)(sid->tagged) & 0x3) << 14) in enetc_streamid_hw_set()
531 } else if (si_conf->id_type == STREAMID_TYPE_SMAC) { in enetc_streamid_hw_set()
532 ether_addr_copy(si_data->smac, sid->src_mac); in enetc_streamid_hw_set()
533 si_data->vid_vidm_tg = (sid->vid & ENETC_CBDR_SID_VID_MASK) + in enetc_streamid_hw_set()
534 ((((u16)(sid->tagged) & 0x3) << 14) in enetc_streamid_hw_set()
538 err = enetc_send_cmd(priv->si, &cbd); in enetc_streamid_hw_set()
540 enetc_cbd_free_data_mem(priv->si, data_size, tmp, &dma); in enetc_streamid_hw_set()
554 port = enetc_pf_to_port(priv->si->pdev); in enetc_streamfilter_hw_set()
556 return -EINVAL; in enetc_streamfilter_hw_set()
558 cbd.index = cpu_to_le16(sfi->index); in enetc_streamfilter_hw_set()
567 sfi_config->en = 0x80; in enetc_streamfilter_hw_set()
569 if (sfi->handle >= 0) { in enetc_streamfilter_hw_set()
570 sfi_config->stream_handle = in enetc_streamfilter_hw_set()
571 cpu_to_le32(sfi->handle); in enetc_streamfilter_hw_set()
572 sfi_config->sthm |= 0x80; in enetc_streamfilter_hw_set()
575 sfi_config->sg_inst_table_index = cpu_to_le16(sfi->gate_id); in enetc_streamfilter_hw_set()
576 sfi_config->input_ports = cpu_to_le32(1 << port); in enetc_streamfilter_hw_set()
581 if (sfi->prio >= 0) in enetc_streamfilter_hw_set()
582 sfi_config->multi |= (sfi->prio & 0x7) | 0x8; in enetc_streamfilter_hw_set()
588 if (sfi->maxsdu) { in enetc_streamfilter_hw_set()
589 sfi_config->msdu = in enetc_streamfilter_hw_set()
590 cpu_to_le16(sfi->maxsdu); in enetc_streamfilter_hw_set()
591 sfi_config->multi |= 0x40; in enetc_streamfilter_hw_set()
594 if (sfi->meter_id >= 0) { in enetc_streamfilter_hw_set()
595 sfi_config->fm_inst_table_index = cpu_to_le16(sfi->meter_id); in enetc_streamfilter_hw_set()
596 sfi_config->multi |= 0x80; in enetc_streamfilter_hw_set()
600 return enetc_send_cmd(priv->si, &cbd); in enetc_streamfilter_hw_set()
621 tmp = enetc_cbd_alloc_data_mem(priv->si, &cbd, data_size, in enetc_streamcounter_hw_get()
624 return -ENOMEM; in enetc_streamcounter_hw_get()
626 err = enetc_send_cmd(priv->si, &cbd); in enetc_streamcounter_hw_get()
630 cnt->matching_frames_count = ((u64)data_buf->matchh << 32) + in enetc_streamcounter_hw_get()
631 data_buf->matchl; in enetc_streamcounter_hw_get()
633 cnt->not_passing_sdu_count = ((u64)data_buf->msdu_droph << 32) + in enetc_streamcounter_hw_get()
634 data_buf->msdu_dropl; in enetc_streamcounter_hw_get()
636 cnt->passing_sdu_count = cnt->matching_frames_count in enetc_streamcounter_hw_get()
637 - cnt->not_passing_sdu_count; in enetc_streamcounter_hw_get()
639 cnt->not_passing_frames_count = in enetc_streamcounter_hw_get()
640 ((u64)data_buf->stream_gate_droph << 32) + in enetc_streamcounter_hw_get()
641 data_buf->stream_gate_dropl; in enetc_streamcounter_hw_get()
643 cnt->passing_frames_count = cnt->matching_frames_count - in enetc_streamcounter_hw_get()
644 cnt->not_passing_sdu_count - in enetc_streamcounter_hw_get()
645 cnt->not_passing_frames_count; in enetc_streamcounter_hw_get()
647 cnt->red_frames_count = ((u64)data_buf->flow_meter_droph << 32) + in enetc_streamcounter_hw_get()
648 data_buf->flow_meter_dropl; in enetc_streamcounter_hw_get()
651 enetc_cbd_free_data_mem(priv->si, data_size, tmp, &dma); in enetc_streamcounter_hw_get()
672 return -EFAULT; in get_start_ns()
697 cbd.index = cpu_to_le16(sgi->index); in enetc_streamgate_hw_set()
704 return enetc_send_cmd(priv->si, &cbd); in enetc_streamgate_hw_set()
706 if (!sgi->num_entries) in enetc_streamgate_hw_set()
709 if (sgi->num_entries > priv->psfp_cap.max_psfp_gatelist || in enetc_streamgate_hw_set()
710 !sgi->cycletime) in enetc_streamgate_hw_set()
711 return -EINVAL; in enetc_streamgate_hw_set()
717 sgi_config->ocgtst = 0x80; in enetc_streamgate_hw_set()
719 sgi_config->oipv = (sgi->init_ipv < 0) ? in enetc_streamgate_hw_set()
720 0x0 : ((sgi->init_ipv & 0x7) | 0x8); in enetc_streamgate_hw_set()
722 sgi_config->en = 0x80; in enetc_streamgate_hw_set()
725 err = enetc_send_cmd(priv->si, &cbd); in enetc_streamgate_hw_set()
727 return -EINVAL; in enetc_streamgate_hw_set()
731 cbd.index = cpu_to_le16(sgi->index); in enetc_streamgate_hw_set()
738 sgcl_config->acl_len = (sgi->num_entries - 1) & 0x3; in enetc_streamgate_hw_set()
740 data_size = struct_size(sgcl_data, sgcl, sgi->num_entries); in enetc_streamgate_hw_set()
741 tmp = enetc_cbd_alloc_data_mem(priv->si, &cbd, data_size, in enetc_streamgate_hw_set()
744 return -ENOMEM; in enetc_streamgate_hw_set()
746 sgce = &sgcl_data->sgcl[0]; in enetc_streamgate_hw_set()
748 sgcl_config->agtst = 0x80; in enetc_streamgate_hw_set()
750 sgcl_data->ct = sgi->cycletime; in enetc_streamgate_hw_set()
751 sgcl_data->cte = sgi->cycletimext; in enetc_streamgate_hw_set()
753 if (sgi->init_ipv >= 0) in enetc_streamgate_hw_set()
754 sgcl_config->aipv = (sgi->init_ipv & 0x7) | 0x8; in enetc_streamgate_hw_set()
756 for (i = 0; i < sgi->num_entries; i++) { in enetc_streamgate_hw_set()
757 struct action_gate_entry *from = &sgi->entries[i]; in enetc_streamgate_hw_set()
760 if (from->gate_state) in enetc_streamgate_hw_set()
761 to->multi |= 0x10; in enetc_streamgate_hw_set()
763 if (from->ipv >= 0) in enetc_streamgate_hw_set()
764 to->multi |= ((from->ipv & 0x7) << 5) | 0x08; in enetc_streamgate_hw_set()
766 if (from->maxoctets >= 0) { in enetc_streamgate_hw_set()
767 to->multi |= 0x01; in enetc_streamgate_hw_set()
768 to->msdu[0] = from->maxoctets & 0xFF; in enetc_streamgate_hw_set()
769 to->msdu[1] = (from->maxoctets >> 8) & 0xFF; in enetc_streamgate_hw_set()
770 to->msdu[2] = (from->maxoctets >> 16) & 0xFF; in enetc_streamgate_hw_set()
773 to->interval = from->interval; in enetc_streamgate_hw_set()
777 now = get_ptp_now(&priv->si->hw); in enetc_streamgate_hw_set()
779 if (sgi->basetime < now) { in enetc_streamgate_hw_set()
782 err = get_start_ns(now, sgi->cycletime, &start); in enetc_streamgate_hw_set()
785 sgcl_data->btl = lower_32_bits(start); in enetc_streamgate_hw_set()
786 sgcl_data->bth = upper_32_bits(start); in enetc_streamgate_hw_set()
788 u32 hi, lo; in enetc_streamgate_hw_set() local
790 hi = upper_32_bits(sgi->basetime); in enetc_streamgate_hw_set()
791 lo = lower_32_bits(sgi->basetime); in enetc_streamgate_hw_set()
792 sgcl_data->bth = hi; in enetc_streamgate_hw_set()
793 sgcl_data->btl = lo; in enetc_streamgate_hw_set()
796 err = enetc_send_cmd(priv->si, &cbd); in enetc_streamgate_hw_set()
799 enetc_cbd_free_data_mem(priv->si, data_size, tmp, &dma); in enetc_streamgate_hw_set()
811 cbd.index = cpu_to_le16((u16)fmi->index); in enetc_flowmeter_hw_set()
816 return enetc_send_cmd(priv->si, &cbd); in enetc_flowmeter_hw_set()
819 fmi_config->en = 0x80; in enetc_flowmeter_hw_set()
821 if (fmi->cir) { in enetc_flowmeter_hw_set()
822 temp = (u64)8000 * fmi->cir; in enetc_flowmeter_hw_set()
826 fmi_config->cir = cpu_to_le32((u32)temp); in enetc_flowmeter_hw_set()
827 fmi_config->cbs = cpu_to_le32(fmi->cbs); in enetc_flowmeter_hw_set()
830 fmi_config->eir = 0; in enetc_flowmeter_hw_set()
831 fmi_config->ebs = 0; in enetc_flowmeter_hw_set()
839 fmi_config->conf = 0; in enetc_flowmeter_hw_set()
841 return enetc_send_cmd(priv->si, &cbd); in enetc_flowmeter_hw_set()
849 if (f->sid.index == index) in enetc_get_stream_by_index()
860 if (g->index == index) in enetc_get_gate_by_index()
871 if (s->index == index) in enetc_get_filter_by_index()
882 if (m->index == index) in enetc_get_meter_by_index()
894 if (s->gate_id == sfi->gate_id && in enetc_psfp_check_sfi()
895 s->prio == sfi->prio && in enetc_psfp_check_sfi()
896 s->maxsdu == sfi->maxsdu && in enetc_psfp_check_sfi()
897 s->meter_id == sfi->meter_id) in enetc_psfp_check_sfi()
905 u32 max_size = priv->psfp_cap.max_psfp_filter; in enetc_get_free_index()
910 return -1; in enetc_get_free_index()
922 z = refcount_dec_and_test(&sfi->refcount); in stream_filter_unref()
926 hlist_del(&sfi->node); in stream_filter_unref()
939 z = refcount_dec_and_test(&sgi->refcount); in stream_gate_unref()
942 hlist_del(&sgi->node); in stream_gate_unref()
954 z = refcount_dec_and_test(&fmi->refcount); in flow_meter_unref()
957 hlist_del(&fmi->node); in flow_meter_unref()
965 if (filter->flags & ENETC_PSFP_FLAGS_FMI) in remove_one_chain()
966 flow_meter_unref(priv, filter->fmi_index); in remove_one_chain()
968 stream_gate_unref(priv, filter->sgi_index); in remove_one_chain()
969 stream_filter_unref(priv, filter->sfi_index); in remove_one_chain()
971 hlist_del(&filter->node); in remove_one_chain()
1032 if (act->police.exceed.act_id != FLOW_ACTION_DROP) { in enetc_psfp_policer_validate()
1035 return -EOPNOTSUPP; in enetc_psfp_policer_validate()
1038 if (act->police.notexceed.act_id != FLOW_ACTION_PIPE && in enetc_psfp_policer_validate()
1039 act->police.notexceed.act_id != FLOW_ACTION_ACCEPT) { in enetc_psfp_policer_validate()
1042 return -EOPNOTSUPP; in enetc_psfp_policer_validate()
1045 if (act->police.notexceed.act_id == FLOW_ACTION_ACCEPT && in enetc_psfp_policer_validate()
1049 return -EOPNOTSUPP; in enetc_psfp_policer_validate()
1052 if (act->police.peakrate_bytes_ps || in enetc_psfp_policer_validate()
1053 act->police.avrate || act->police.overhead) { in enetc_psfp_policer_validate()
1056 return -EOPNOTSUPP; in enetc_psfp_policer_validate()
1059 if (act->police.rate_pkt_ps) { in enetc_psfp_policer_validate()
1062 return -EOPNOTSUPP; in enetc_psfp_policer_validate()
1073 struct netlink_ext_ack *extack = f->common.extack; in enetc_psfp_parse_clsflower()
1084 if (f->common.chain_index >= priv->psfp_cap.max_streamid) { in enetc_psfp_parse_clsflower()
1086 return -ENOSPC; in enetc_psfp_parse_clsflower()
1089 flow_action_for_each(i, entry, &rule->action) in enetc_psfp_parse_clsflower()
1090 if (entry->id == FLOW_ACTION_GATE) in enetc_psfp_parse_clsflower()
1092 else if (entry->id == FLOW_ACTION_POLICE) in enetc_psfp_parse_clsflower()
1097 return -EINVAL; in enetc_psfp_parse_clsflower()
1101 return -ENOMEM; in enetc_psfp_parse_clsflower()
1103 filter->sid.index = f->common.chain_index; in enetc_psfp_parse_clsflower()
1110 if (!is_zero_ether_addr(match.mask->dst) && in enetc_psfp_parse_clsflower()
1111 !is_zero_ether_addr(match.mask->src)) { in enetc_psfp_parse_clsflower()
1114 err = -EINVAL; in enetc_psfp_parse_clsflower()
1118 if (!is_zero_ether_addr(match.mask->dst)) { in enetc_psfp_parse_clsflower()
1119 if (!is_broadcast_ether_addr(match.mask->dst)) { in enetc_psfp_parse_clsflower()
1122 err = -EINVAL; in enetc_psfp_parse_clsflower()
1125 ether_addr_copy(filter->sid.dst_mac, match.key->dst); in enetc_psfp_parse_clsflower()
1126 filter->sid.filtertype = STREAMID_TYPE_NULL; in enetc_psfp_parse_clsflower()
1129 if (!is_zero_ether_addr(match.mask->src)) { in enetc_psfp_parse_clsflower()
1130 if (!is_broadcast_ether_addr(match.mask->src)) { in enetc_psfp_parse_clsflower()
1133 err = -EINVAL; in enetc_psfp_parse_clsflower()
1136 ether_addr_copy(filter->sid.src_mac, match.key->src); in enetc_psfp_parse_clsflower()
1137 filter->sid.filtertype = STREAMID_TYPE_SMAC; in enetc_psfp_parse_clsflower()
1141 err = -EINVAL; in enetc_psfp_parse_clsflower()
1149 if (match.mask->vlan_priority) { in enetc_psfp_parse_clsflower()
1150 if (match.mask->vlan_priority != in enetc_psfp_parse_clsflower()
1153 err = -EINVAL; in enetc_psfp_parse_clsflower()
1158 if (match.mask->vlan_id) { in enetc_psfp_parse_clsflower()
1159 if (match.mask->vlan_id != VLAN_VID_MASK) { in enetc_psfp_parse_clsflower()
1161 err = -EINVAL; in enetc_psfp_parse_clsflower()
1165 filter->sid.vid = match.key->vlan_id; in enetc_psfp_parse_clsflower()
1166 if (!filter->sid.vid) in enetc_psfp_parse_clsflower()
1167 filter->sid.tagged = STREAMID_VLAN_UNTAGGED; in enetc_psfp_parse_clsflower()
1169 filter->sid.tagged = STREAMID_VLAN_TAGGED; in enetc_psfp_parse_clsflower()
1172 filter->sid.tagged = STREAMID_VLAN_ALL; in enetc_psfp_parse_clsflower()
1176 if (entryg->hw_index >= priv->psfp_cap.max_psfp_gate) { in enetc_psfp_parse_clsflower()
1178 err = -ENOSPC; in enetc_psfp_parse_clsflower()
1182 if (entryg->gate.num_entries >= priv->psfp_cap.max_psfp_gatelist) { in enetc_psfp_parse_clsflower()
1184 err = -ENOSPC; in enetc_psfp_parse_clsflower()
1188 entries_size = struct_size(sgi, entries, entryg->gate.num_entries); in enetc_psfp_parse_clsflower()
1191 err = -ENOMEM; in enetc_psfp_parse_clsflower()
1195 refcount_set(&sgi->refcount, 1); in enetc_psfp_parse_clsflower()
1196 sgi->index = entryg->hw_index; in enetc_psfp_parse_clsflower()
1197 sgi->init_ipv = entryg->gate.prio; in enetc_psfp_parse_clsflower()
1198 sgi->basetime = entryg->gate.basetime; in enetc_psfp_parse_clsflower()
1199 sgi->cycletime = entryg->gate.cycletime; in enetc_psfp_parse_clsflower()
1200 sgi->num_entries = entryg->gate.num_entries; in enetc_psfp_parse_clsflower()
1202 e = sgi->entries; in enetc_psfp_parse_clsflower()
1203 for (i = 0; i < entryg->gate.num_entries; i++) { in enetc_psfp_parse_clsflower()
1204 e[i].gate_state = entryg->gate.entries[i].gate_state; in enetc_psfp_parse_clsflower()
1205 e[i].interval = entryg->gate.entries[i].interval; in enetc_psfp_parse_clsflower()
1206 e[i].ipv = entryg->gate.entries[i].ipv; in enetc_psfp_parse_clsflower()
1207 e[i].maxoctets = entryg->gate.entries[i].maxoctets; in enetc_psfp_parse_clsflower()
1210 filter->sgi_index = sgi->index; in enetc_psfp_parse_clsflower()
1214 err = -ENOMEM; in enetc_psfp_parse_clsflower()
1218 refcount_set(&sfi->refcount, 1); in enetc_psfp_parse_clsflower()
1219 sfi->gate_id = sgi->index; in enetc_psfp_parse_clsflower()
1220 sfi->meter_id = ENETC_PSFP_WILDCARD; in enetc_psfp_parse_clsflower()
1224 err = enetc_psfp_policer_validate(&rule->action, entryp, extack); in enetc_psfp_parse_clsflower()
1228 if (entryp->police.burst) { in enetc_psfp_parse_clsflower()
1231 err = -ENOMEM; in enetc_psfp_parse_clsflower()
1234 refcount_set(&fmi->refcount, 1); in enetc_psfp_parse_clsflower()
1235 fmi->cir = entryp->police.rate_bytes_ps; in enetc_psfp_parse_clsflower()
1236 fmi->cbs = entryp->police.burst; in enetc_psfp_parse_clsflower()
1237 fmi->index = entryp->hw_index; in enetc_psfp_parse_clsflower()
1238 filter->flags |= ENETC_PSFP_FLAGS_FMI; in enetc_psfp_parse_clsflower()
1239 filter->fmi_index = fmi->index; in enetc_psfp_parse_clsflower()
1240 sfi->meter_id = fmi->index; in enetc_psfp_parse_clsflower()
1243 if (entryp->police.mtu) in enetc_psfp_parse_clsflower()
1244 sfi->maxsdu = entryp->police.mtu; in enetc_psfp_parse_clsflower()
1248 if (f->common.prio && f->common.prio <= BIT(3)) in enetc_psfp_parse_clsflower()
1249 sfi->prio = f->common.prio - 1; in enetc_psfp_parse_clsflower()
1251 sfi->prio = ENETC_PSFP_WILDCARD; in enetc_psfp_parse_clsflower()
1258 if (sfi->handle < 0) { in enetc_psfp_parse_clsflower()
1260 err = -ENOSPC; in enetc_psfp_parse_clsflower()
1264 sfi->index = index; in enetc_psfp_parse_clsflower()
1265 sfi->handle = index + HANDLE_OFFSET; in enetc_psfp_parse_clsflower()
1267 filter->sid.handle = sfi->handle; in enetc_psfp_parse_clsflower()
1268 filter->sfi_index = sfi->index; in enetc_psfp_parse_clsflower()
1271 filter->sfi_index = old_sfi->index; in enetc_psfp_parse_clsflower()
1272 filter->sid.handle = old_sfi->handle; in enetc_psfp_parse_clsflower()
1276 err = enetc_psfp_hw_set(priv, &filter->sid, in enetc_psfp_parse_clsflower()
1282 if (filter->flags & ENETC_PSFP_FLAGS_FMI) { in enetc_psfp_parse_clsflower()
1283 old_fmi = enetc_get_meter_by_index(filter->fmi_index); in enetc_psfp_parse_clsflower()
1285 fmi->refcount = old_fmi->refcount; in enetc_psfp_parse_clsflower()
1286 refcount_set(&fmi->refcount, in enetc_psfp_parse_clsflower()
1287 refcount_read(&old_fmi->refcount) + 1); in enetc_psfp_parse_clsflower()
1288 hlist_del(&old_fmi->node); in enetc_psfp_parse_clsflower()
1291 hlist_add_head(&fmi->node, &epsfp.psfp_meter_list); in enetc_psfp_parse_clsflower()
1295 old_sgi = enetc_get_gate_by_index(filter->sgi_index); in enetc_psfp_parse_clsflower()
1297 refcount_set(&sgi->refcount, in enetc_psfp_parse_clsflower()
1298 refcount_read(&old_sgi->refcount) + 1); in enetc_psfp_parse_clsflower()
1299 hlist_del(&old_sgi->node); in enetc_psfp_parse_clsflower()
1303 hlist_add_head(&sgi->node, &epsfp.psfp_gate_list); in enetc_psfp_parse_clsflower()
1306 hlist_add_head(&sfi->node, &epsfp.psfp_filter_list); in enetc_psfp_parse_clsflower()
1307 set_bit(sfi->index, epsfp.psfp_sfi_bitmap); in enetc_psfp_parse_clsflower()
1310 refcount_inc(&old_sfi->refcount); in enetc_psfp_parse_clsflower()
1313 old_filter = enetc_get_stream_by_index(filter->sid.index); in enetc_psfp_parse_clsflower()
1317 filter->stats.lastused = jiffies; in enetc_psfp_parse_clsflower()
1318 hlist_add_head(&filter->node, &epsfp.stream_list); in enetc_psfp_parse_clsflower()
1340 struct netlink_ext_ack *extack = cls_flower->common.extack; in enetc_config_clsflower()
1341 struct flow_dissector *dissector = rule->match.dissector; in enetc_config_clsflower()
1342 struct flow_action *action = &rule->action; in enetc_config_clsflower()
1350 return -EINVAL; in enetc_config_clsflower()
1354 actions |= BIT(entry->id); in enetc_config_clsflower()
1356 fwd = enetc_check_flow_actions(actions, dissector->used_keys); in enetc_config_clsflower()
1359 return -EOPNOTSUPP; in enetc_config_clsflower()
1362 if (fwd->output & FILTER_ACTION_TYPE_PSFP) { in enetc_config_clsflower()
1370 return -EOPNOTSUPP; in enetc_config_clsflower()
1380 struct netlink_ext_ack *extack = f->common.extack; in enetc_psfp_destroy_clsflower()
1383 if (f->common.chain_index >= priv->psfp_cap.max_streamid) { in enetc_psfp_destroy_clsflower()
1385 return -ENOSPC; in enetc_psfp_destroy_clsflower()
1388 filter = enetc_get_stream_by_index(f->common.chain_index); in enetc_psfp_destroy_clsflower()
1390 return -EINVAL; in enetc_psfp_destroy_clsflower()
1392 err = enetc_streamid_hw_set(priv, &filter->sid, false); in enetc_psfp_destroy_clsflower()
1415 filter = enetc_get_stream_by_index(f->common.chain_index); in enetc_psfp_get_stats()
1417 return -EINVAL; in enetc_psfp_get_stats()
1419 err = enetc_streamcounter_hw_get(priv, filter->sfi_index, &counters); in enetc_psfp_get_stats()
1421 return -EINVAL; in enetc_psfp_get_stats()
1425 counters.not_passing_sdu_count - in enetc_psfp_get_stats()
1426 filter->stats.pkts; in enetc_psfp_get_stats()
1429 counters.red_frames_count - in enetc_psfp_get_stats()
1430 filter->stats.drops; in enetc_psfp_get_stats()
1431 stats.lastused = filter->stats.lastused; in enetc_psfp_get_stats()
1432 filter->stats.pkts += stats.pkts; in enetc_psfp_get_stats()
1433 filter->stats.drops += stats.drops; in enetc_psfp_get_stats()
1436 flow_stats_update(&f->stats, 0x0, stats.pkts, stats.drops, in enetc_psfp_get_stats()
1445 switch (cls_flower->command) { in enetc_setup_tc_cls_flower()
1453 return -EOPNOTSUPP; in enetc_setup_tc_cls_flower()
1469 hlist_del(&s->node); in clean_stream_list()
1480 hlist_del(&sfi->node); in clean_sfi_list()
1491 hlist_del(&sgi->node); in clean_sgi_list()
1512 return -EOPNOTSUPP; in enetc_setup_tc_block_cb()
1518 return -EOPNOTSUPP; in enetc_setup_tc_block_cb()
1522 int enetc_set_psfp(struct net_device *ndev, bool en) in enetc_set_psfp() argument
1527 if (en) { in enetc_set_psfp()
1532 priv->active_offloads |= ENETC_F_QCI; in enetc_set_psfp()
1540 priv->active_offloads &= ~ENETC_F_QCI; in enetc_set_psfp()
1550 epsfp.psfp_sfi_bitmap = bitmap_zalloc(priv->psfp_cap.max_psfp_filter, in enetc_psfp_init()
1553 return -ENOMEM; in enetc_psfp_init()
1566 return -EBUSY; in enetc_psfp_clean()
1585 switch (f->command) { in enetc_setup_tc_psfp()
1587 port = enetc_pf_to_port(priv->si->pdev); in enetc_setup_tc_psfp()
1589 return -EINVAL; in enetc_setup_tc_psfp()
1594 port = enetc_pf_to_port(priv->si->pdev); in enetc_setup_tc_psfp()
1596 return -EINVAL; in enetc_setup_tc_psfp()
1611 struct enetc_si *si = priv->si; in enetc_qos_query_caps()
1613 switch (base->type) { in enetc_qos_query_caps()
1615 struct tc_taprio_caps *caps = base->caps; in enetc_qos_query_caps()
1617 if (si->hw_features & ENETC_SI_F_QBV) in enetc_qos_query_caps()
1618 caps->supports_queue_max_sdu = true; in enetc_qos_query_caps()
1623 return -EOPNOTSUPP; in enetc_qos_query_caps()