From: Sergey Ryazanov Date: Wed, 22 Jan 2025 22:26:53 +0000 (+0200) Subject: ipq40xx: fix compatibility with linux-atm tools X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=6d6dc3a3c967174598a44503f4af281574660356;p=openwrt%2Fstaging%2Fjow.git ipq40xx: fix compatibility with linux-atm tools atm_qos struct should be the same both for user and kernel spaces. Via the __SO_ENCODE() macro it is used to define the SO_ATMQOS socket IOC. During the VRX518 support introduction, the atm_trafprm sturct nested into the atm_qos stucture was update with newer fields that are referenced by the ATM TC layer of the VRX518 TC driver. These new fields are intended to communicate information for extra traffic classes supported by the driver. But we are still using vanilla kernel headers to build the toolchain. Due to the atm.h header incoherency br2684ctl from linux-atm tools is incapable to configure the ATM bridge netdev: br2684ctl: Interface "dsl0" created sucessfully br2684ctl: Communicating over ATM 0.1.2, encapsulation: LLC br2684ctl: setsockopt SO_ATMQOS 22 <-- EINVAL errno br2684ctl: Fatal: failed to connect on socket; File descriptor in bad state There are two options to fix this incoherency. (a) update the header file in the toolchain to build linux-atm against updated atm_trafprm and atm_qos structures, or (b) revert atm_trafprm changes. Since there are no actual users of the extra ATM QoS traffic classes, just drop these extra traffic classes from vrx518_tc ATM TC layer and drop the kernel patch updating atm.h. Besides fixing the compatibility with linux-atm tools, removing the kernel patch should simplify kernel updates removing unneeded burden of maintenance. Run tested with FRITZ!Box 7530 with disabled extra traffic classes and then removed them entirely before the submission. CC: John Crispin Fixes: cfd42a0098 ("ipq40xx: add Intel/Lantiq ATM hacks") Suggested-by: Andre Heider Reported-and-tested-by: nebibigon93@yandex.ru Signed-off-by: Sergey Ryazanov Link: https://patchwork.ozlabs.org/project/openwrt/patch/20250122222654.21833-4-ryazanov.s.a@gmail.com/ Signed-off-by: Hauke Mehrtens --- diff --git a/package/kernel/lantiq/vrx518_tc/patches/101-dcdp-atm_tc-drop-extra-qos-classes.patch b/package/kernel/lantiq/vrx518_tc/patches/101-dcdp-atm_tc-drop-extra-qos-classes.patch new file mode 100644 index 0000000000..5c7b246545 --- /dev/null +++ b/package/kernel/lantiq/vrx518_tc/patches/101-dcdp-atm_tc-drop-extra-qos-classes.patch @@ -0,0 +1,144 @@ +Extra ATM traffic classes requires atm_qos struct extension and a set of +new defines. What itself requires atm.h updates both in the kernel and +in the toolchain. On another hand we do not have any real users of these +traffic classes. + +In absence of real user there are no benefits to support this +functionality. There is only the burden of maintenance of extra patches +all around the building framework. So just drop these extra QoS traffic +classes in order to facilitate maintenance and avoid side effects like +breaking compatibility with existing userspace tools like linux-atm. + +Signed-off-by: Sergey Ryazanov +-- +--- a/dcdp/atm_tc.c ++++ b/dcdp/atm_tc.c +@@ -463,34 +463,9 @@ static void set_qsb(struct atm_priv *pri + /* Weighted Fair Queueing Factor (WFQF) */ + switch (qos->txtp.traffic_class) { + case ATM_CBR: +- case ATM_VBR_RT: + /* real time queue gets weighted fair queueing bypass */ + q_parm_tbl.bit.wfqf = 0; + break; +- case ATM_VBR_NRT: +- case ATM_UBR_PLUS: +- /* WFQF calculation here is based on virtual cell rates, +- to reduce granularity for high rates +- */ +- /* WFQF is maximum cell rate / garenteed cell rate */ +- /* wfqf = qsb_minimum_cell_rate * QSB_WFQ_NONUBR_MAX / +- requested_minimum_peak_cell_rate +- */ +- if (qos->txtp.min_pcr == 0) +- q_parm_tbl.bit.wfqf = QSB_WFQ_NONUBR_MAX; +- else { +- tmp = QSB_GCR_MIN * QSB_WFQ_NONUBR_MAX / +- qos->txtp.min_pcr; +- if (tmp == 0) +- q_parm_tbl.bit.wfqf = 1; +- else if (tmp > QSB_WFQ_NONUBR_MAX) +- q_parm_tbl.bit.wfqf +- = QSB_WFQ_NONUBR_MAX; +- else +- q_parm_tbl.bit.wfqf = tmp; +- } +- break; +- + case ATM_UBR: + default: + q_parm_tbl.bit.wfqf = QSB_WFQ_UBR_BYPASS; +@@ -498,42 +473,9 @@ static void set_qsb(struct atm_priv *pri + } + + /* Sustained Cell Rate (SCR) Leaky Bucket Shaper VBR.0/VBR.1 */ +- if (qos->txtp.traffic_class == ATM_VBR_RT || +- qos->txtp.traffic_class == ATM_VBR_NRT) { +- if (qos->txtp.scr == 0) { +- /* disable shaper */ +- q_vbr_parm_tbl.bit.taus = 0; +- q_vbr_parm_tbl.bit.ts = 0; +- } else { +- /* Cell Loss Priority (CLP) */ +- if ((vcc->atm_options & ATM_ATMOPT_CLP)) +- /* CLP1 */ +- q_parm_tbl.bit.vbr = 1; +- else +- /* CLP0 */ +- q_parm_tbl.bit.vbr = 0; +- /* Rate Shaper Parameter (TS) and +- Burst Tolerance Parameter for SCR (tauS) +- */ +- tmp = ((qsb_clk * param->qsb_tstep) >> 5) / +- qos->txtp.scr + 1; +- q_vbr_parm_tbl.bit.ts +- = tmp > QSB_TP_TS_MAX ? QSB_TP_TS_MAX : tmp; +- tmp = (qos->txtp.mbs - 1) * +- (q_vbr_parm_tbl.bit.ts - +- q_parm_tbl.bit.tp) / 64; +- if (tmp == 0) +- q_vbr_parm_tbl.bit.taus = 1; +- else if (tmp > QSB_TAUS_MAX) +- q_vbr_parm_tbl.bit.taus +- = QSB_TAUS_MAX; +- else +- q_vbr_parm_tbl.bit.taus = tmp; +- } +- } else { +- q_vbr_parm_tbl.bit.taus = 0; +- q_vbr_parm_tbl.bit.ts = 0; +- } ++ /* NB: shaper disabled since there no user interface to activate it */ ++ q_vbr_parm_tbl.bit.taus = 0; ++ q_vbr_parm_tbl.bit.ts = 0; + + /* Queue Parameter Table (QPT) */ + tc_w32(QSB_QPT_SET_MASK, QSB_RTM); +@@ -1064,15 +1006,6 @@ static int ppe_open(struct atm_vcc *vcc) + /* check bandwidth */ + if ((vcc->qos.txtp.traffic_class == ATM_CBR && + vcc->qos.txtp.max_pcr > +- (port->tx_max_cell_rate - port->tx_used_cell_rate)) +- || (vcc->qos.txtp.traffic_class == ATM_VBR_RT && +- vcc->qos.txtp.max_pcr > +- (port->tx_max_cell_rate - port->tx_used_cell_rate)) +- || (vcc->qos.txtp.traffic_class == ATM_VBR_NRT && +- vcc->qos.txtp.scr > +- (port->tx_max_cell_rate - port->tx_used_cell_rate)) +- || (vcc->qos.txtp.traffic_class == ATM_UBR_PLUS && +- vcc->qos.txtp.min_pcr > + (port->tx_max_cell_rate - port->tx_used_cell_rate))) { + tc_dbg(priv->tc_priv, MSG_INIT, "exceed TX line rate\n"); + return -EINVAL; +@@ -1128,15 +1061,8 @@ static int ppe_open(struct atm_vcc *vcc) + /* reserve bandwidth */ + switch (vcc->qos.txtp.traffic_class) { + case ATM_CBR: +- case ATM_VBR_RT: + port->tx_used_cell_rate += vcc->qos.txtp.max_pcr; + break; +- case ATM_VBR_NRT: +- port->tx_used_cell_rate += vcc->qos.txtp.scr; +- break; +- case ATM_UBR_PLUS: +- port->tx_used_cell_rate += vcc->qos.txtp.min_pcr; +- break; + } + + /* update atm_vcc structure */ +@@ -1222,15 +1148,8 @@ static void ppe_close(struct atm_vcc *vc + /* release bandwidth */ + switch (vcc->qos.txtp.traffic_class) { + case ATM_CBR: +- case ATM_VBR_RT: + port->tx_used_cell_rate -= vcc->qos.txtp.max_pcr; + break; +- case ATM_VBR_NRT: +- port->tx_used_cell_rate -= vcc->qos.txtp.scr; +- break; +- case ATM_UBR_PLUS: +- port->tx_used_cell_rate -= vcc->qos.txtp.min_pcr; +- break; + } + + /* idle for a while to let parallel operation finish */ diff --git a/package/kernel/lantiq/vrx518_tc/patches/200-swplat.patch b/package/kernel/lantiq/vrx518_tc/patches/200-swplat.patch index 6596a8b913..930fa6632c 100644 --- a/package/kernel/lantiq/vrx518_tc/patches/200-swplat.patch +++ b/package/kernel/lantiq/vrx518_tc/patches/200-swplat.patch @@ -3,7 +3,7 @@ This replaces it by a basic working implementation. --- a/dcdp/atm_tc.c +++ b/dcdp/atm_tc.c -@@ -603,7 +603,11 @@ static void atm_aca_init(struct atm_priv +@@ -545,7 +545,11 @@ static void atm_aca_init(struct atm_priv cfg = &priv->tc_priv->cfg; txin = ¶m.aca_txin; @@ -15,7 +15,7 @@ This replaces it by a basic working implementation. txin->hd_size_in_dw = cfg->txin.soc_desc_dwsz; txin->pd_desc_base = SB_XBAR_ADDR(__ACA_TX_IN_PD_LIST_BASE); txin->pd_desc_num = __ACA_TX_IN_PD_LIST_NUM; -@@ -625,7 +629,11 @@ static void atm_aca_init(struct atm_priv +@@ -567,7 +571,11 @@ static void atm_aca_init(struct atm_priv txin->soc_cmlt_cnt_addr); txout = ¶m.aca_txout; @@ -27,7 +27,7 @@ This replaces it by a basic working implementation. txout->hd_size_in_dw = cfg->txout.soc_desc_dwsz; txout->pd_desc_base = SB_XBAR_ADDR(__ACA_TX_OUT_PD_LIST_BASE); txout->pd_desc_num = __ACA_TX_OUT_PD_LIST_NUM; -@@ -647,7 +655,11 @@ static void atm_aca_init(struct atm_priv +@@ -589,7 +597,11 @@ static void atm_aca_init(struct atm_priv txout->soc_cmlt_cnt_addr); rxout = ¶m.aca_rxout; @@ -39,7 +39,7 @@ This replaces it by a basic working implementation. rxout->hd_size_in_dw = cfg->rxout.soc_desc_dwsz; rxout->pd_desc_base = SB_XBAR_ADDR(__ACA_RX_OUT_PD_LIST_BASE); rxout->pd_desc_num = __ACA_RX_OUT_PD_LIST_NUM; -@@ -669,7 +681,11 @@ static void atm_aca_init(struct atm_priv +@@ -611,7 +623,11 @@ static void atm_aca_init(struct atm_priv rxout->soc_cmlt_cnt_addr); rxin = ¶m.aca_rxin; @@ -51,7 +51,7 @@ This replaces it by a basic working implementation. rxin->hd_size_in_dw = cfg->rxin.soc_desc_dwsz; rxin->pd_desc_base = SB_XBAR_ADDR(__RX_IN_PD_DES_LIST_BASE); rxin->pd_desc_num = __ACA_RX_IN_PD_LIST_NUM; -@@ -1261,7 +1277,7 @@ static int ppe_ioctl(struct atm_dev *dev +@@ -1180,7 +1196,7 @@ static int ppe_ioctl(struct atm_dev *dev static int ppe_send(struct atm_vcc *vcc, struct sk_buff *skb) { int ret, qid, mpoa_pt, mpoa_type, vid; @@ -60,7 +60,7 @@ This replaces it by a basic working implementation. struct atm_priv *priv; if (!vcc) { -@@ -1327,12 +1343,14 @@ static int ppe_send(struct atm_vcc *vcc, +@@ -1246,12 +1262,14 @@ static int ppe_send(struct atm_vcc *vcc, tc_dbg(priv->tc_priv, MSG_TX, "vid: 0x%x, qid: 0x%x\n", vid, qid); diff --git a/package/kernel/lantiq/vrx518_tc/patches/202-napi.patch b/package/kernel/lantiq/vrx518_tc/patches/202-napi.patch index 266beba1a7..75d18138c0 100644 --- a/package/kernel/lantiq/vrx518_tc/patches/202-napi.patch +++ b/package/kernel/lantiq/vrx518_tc/patches/202-napi.patch @@ -296,7 +296,7 @@ priv->tc_ops.umt_start = plat_umt_start; --- a/dcdp/atm_tc.c +++ b/dcdp/atm_tc.c -@@ -3650,7 +3650,7 @@ static void atm_aca_ring_config_init(str +@@ -3569,7 +3569,7 @@ static void atm_aca_ring_config_init(str static int atm_ring_init(struct atm_priv *priv) { atm_aca_ring_config_init(priv); @@ -305,7 +305,7 @@ } static int atm_init(struct tc_priv *tcpriv, u32 ep_id) -@@ -4020,7 +4020,7 @@ void atm_tc_unload(void) +@@ -3939,7 +3939,7 @@ void atm_tc_unload(void) /* unregister device */ if (priv->tc_priv->tc_ops.dev_unreg != NULL) priv->tc_priv->tc_ops.dev_unreg(NULL, diff --git a/package/kernel/lantiq/vrx518_tc/patches/204-dcdp-atm_tc-fix-compilation-warning.patch b/package/kernel/lantiq/vrx518_tc/patches/204-dcdp-atm_tc-fix-compilation-warning.patch index bf2d82e2b5..1b70a663cd 100644 --- a/package/kernel/lantiq/vrx518_tc/patches/204-dcdp-atm_tc-fix-compilation-warning.patch +++ b/package/kernel/lantiq/vrx518_tc/patches/204-dcdp-atm_tc-fix-compilation-warning.patch @@ -1,6 +1,6 @@ --- a/dcdp/atm_tc.c +++ b/dcdp/atm_tc.c -@@ -746,7 +746,8 @@ static void atm_aca_init(struct atm_priv +@@ -688,7 +688,8 @@ static void atm_aca_init(struct atm_priv ACA_TXOUT_EN | ACA_RXIN_EN | ACA_RXOUT_EN, 1); } @@ -10,7 +10,7 @@ { struct tm nowtm; char tmbuf[64]; -@@ -765,7 +766,8 @@ static int print_datetime(char *buffer, +@@ -707,7 +708,8 @@ static int print_datetime(char *buffer, nowtm.tm_hour, nowtm.tm_min, nowtm.tm_sec); @@ -20,7 +20,7 @@ return 0; } -@@ -967,7 +969,7 @@ void show_atm_pvc(struct seq_file *seq, +@@ -909,7 +911,7 @@ void show_atm_pvc(struct seq_file *seq, char buf[64]; seq_printf(seq, "\tNet device: %s\n", pvc->dev->name); diff --git a/package/kernel/lantiq/vrx518_tc/patches/207-dcdp-atm_tc-fix-crash-on-subif_reg-absence.patch b/package/kernel/lantiq/vrx518_tc/patches/207-dcdp-atm_tc-fix-crash-on-subif_reg-absence.patch index 87456424c3..f268c0908c 100644 --- a/package/kernel/lantiq/vrx518_tc/patches/207-dcdp-atm_tc-fix-crash-on-subif_reg-absence.patch +++ b/package/kernel/lantiq/vrx518_tc/patches/207-dcdp-atm_tc-fix-crash-on-subif_reg-absence.patch @@ -23,7 +23,7 @@ Signed-off-by: Sergey Ryazanov --- --- a/dcdp/atm_tc.c +++ b/dcdp/atm_tc.c -@@ -1232,8 +1232,9 @@ static void ppe_close(struct atm_vcc *vc +@@ -1158,8 +1158,9 @@ static void ppe_close(struct atm_vcc *vc validate_oam_htu_entry(priv, 0); spin_unlock_bh(&priv->atm_lock); @@ -35,7 +35,7 @@ Signed-off-by: Sergey Ryazanov memset(conn, 0, sizeof(*conn)); -@@ -2791,24 +2792,26 @@ static void mpoa_setup_sync(struct atm_p +@@ -2710,24 +2711,26 @@ static void mpoa_setup_sync(struct atm_p struct wtx_queue_config_t tx_qcfg; struct uni_cell_header *cell_header; struct atm_vcc *vcc; diff --git a/target/linux/ipq40xx/patches-6.6/998-lantiq-atm-hacks.patch b/target/linux/ipq40xx/patches-6.6/998-lantiq-atm-hacks.patch deleted file mode 100644 index c15a4b3ae3..0000000000 --- a/target/linux/ipq40xx/patches-6.6/998-lantiq-atm-hacks.patch +++ /dev/null @@ -1,43 +0,0 @@ -From: John Crispin -Date: Fri, 3 Aug 2012 10:27:25 +0200 -Subject: [PATCH 04/36] MIPS: lantiq: add atm hack - -Signed-off-by: John Crispin ---- a/include/uapi/linux/atm.h -+++ b/include/uapi/linux/atm.h -@@ -131,8 +131,14 @@ - #define ATM_ABR 4 - #define ATM_ANYCLASS 5 /* compatible with everything */ - -+#define ATM_VBR_NRT ATM_VBR -+#define ATM_VBR_RT 6 -+#define ATM_UBR_PLUS 7 -+#define ATM_GFR 8 -+ - #define ATM_MAX_PCR -1 /* maximum available PCR */ - -+ - struct atm_trafprm { - unsigned char traffic_class; /* traffic class (ATM_UBR, ...) */ - int max_pcr; /* maximum PCR in cells per second */ -@@ -155,6 +161,9 @@ struct atm_trafprm { - unsigned int adtf :10; /* ACR Decrease Time Factor (10-bit) */ - unsigned int cdf :3; /* Cutoff Decrease Factor (3-bit) */ - unsigned int spare :9; /* spare bits */ -+ int scr; /* sustained rate in cells per second */ -+ int mbs; /* maximum burst size (MBS) in cells */ -+ int cdv; /* Cell delay variation */ - }; - - struct atm_qos { ---- a/net/atm/proc.c -+++ b/net/atm/proc.c -@@ -141,7 +141,7 @@ static void *vcc_seq_next(struct seq_fil - static void pvc_info(struct seq_file *seq, struct atm_vcc *vcc) - { - static const char *const class_name[] = { -- "off", "UBR", "CBR", "VBR", "ABR"}; -+ "off","UBR","CBR","NTR-VBR","ABR","ANY","RT-VBR","UBR+","GFR"}; - static const char *const aal_name[] = { - "---", "1", "2", "3/4", /* 0- 3 */ - "???", "5", "???", "???", /* 4- 7 */