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 vanila kernel headers
to build the toolchain. Due to the atm.h header incoherency br2684ctl
from linux-atm tools is incapable to configure an 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 user space users of the extra ATM QoS traffic
classes, just remove new fields from the atm_trafprm structure and
disable the corresponding functionality in the VRX518 TC driver.

Actually the new fields were just commented out and a comment was placed
next to them explaining who is referencing these fields and why they are
disabled for now.

Run tested with FRITZ!Box 7530.

Fixes: cfd42a0098 ("ipq40xx: add Intel/Lantiq ATM hacks")
Reported-and-tested-by: nebibigo...@yandex.ru
Signed-off-by: Sergey Ryazanov <ryazanov....@gmail.com>
---
 .../101-disable-extra-atm-qos-classes.patch   | 66 +++++++++++++++++++
 .../lantiq/vrx518_tc/patches/200-swplat.patch | 12 ++--
 .../lantiq/vrx518_tc/patches/202-napi.patch   |  4 +-
 ...-dcdp-atm_tc-fix-compilation-warning.patch |  6 +-
 ...tm_tc-fix-crash-on-subif_reg-absence.patch |  4 +-
 .../patches-6.6/998-lantiq-atm-hacks.patch    |  8 ++-
 6 files changed, 86 insertions(+), 14 deletions(-)
 create mode 100644 
package/kernel/lantiq/vrx518_tc/patches/101-disable-extra-atm-qos-classes.patch

diff --git 
a/package/kernel/lantiq/vrx518_tc/patches/101-disable-extra-atm-qos-classes.patch
 
b/package/kernel/lantiq/vrx518_tc/patches/101-disable-extra-atm-qos-classes.patch
new file mode 100644
index 0000000000..159cf1d082
--- /dev/null
+++ 
b/package/kernel/lantiq/vrx518_tc/patches/101-disable-extra-atm-qos-classes.patch
@@ -0,0 +1,66 @@
+Extra ATM traffic classes requires atm_qos struct extension what either
+requires atm.h header update in the toolchain or breaks backward
+compatibility with linux-atm tools due to usage of __SO_ENCODE macro
+depending on the structure size. So just disable this unused
+functionality to keep atm_qos struct intact and keep compatibility.
+
+Signed-off-by: Sergey Ryazanov <ryazanov....@gmail.com>
+--
+--- a/dcdp/atm_tc.c
++++ b/dcdp/atm_tc.c
+@@ -500,6 +500,15 @@ 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 1
++              /* Unconditionally disable shaper since there are no real users
++               * and corresponding extra atm_qos fields break backward
++               * compatibility with linux-atm tools, so these extra fields
++               * were removed.
++               */
++              q_vbr_parm_tbl.bit.taus = 0;
++              q_vbr_parm_tbl.bit.ts = 0;
++#else
+               if (qos->txtp.scr == 0) {
+                       /* disable shaper */
+                       q_vbr_parm_tbl.bit.taus = 0;
+@@ -530,6 +539,7 @@ static void set_qsb(struct atm_priv *pri
+                       else
+                               q_vbr_parm_tbl.bit.taus = tmp;
+               }
++#endif
+       } else {
+               q_vbr_parm_tbl.bit.taus = 0;
+               q_vbr_parm_tbl.bit.ts = 0;
+@@ -1068,9 +1078,11 @@ static int ppe_open(struct atm_vcc *vcc)
+               || (vcc->qos.txtp.traffic_class == ATM_VBR_RT &&
+               vcc->qos.txtp.max_pcr >
+                       (port->tx_max_cell_rate - port->tx_used_cell_rate))
++#if 0         /* Disabled to keep atm_qos struct untouched */
+               || (vcc->qos.txtp.traffic_class == ATM_VBR_NRT &&
+               vcc->qos.txtp.scr >
+                       (port->tx_max_cell_rate - port->tx_used_cell_rate))
++#endif
+               || (vcc->qos.txtp.traffic_class == ATM_UBR_PLUS &&
+               vcc->qos.txtp.min_pcr >
+                       (port->tx_max_cell_rate - port->tx_used_cell_rate))) {
+@@ -1132,7 +1144,9 @@ static int ppe_open(struct atm_vcc *vcc)
+               port->tx_used_cell_rate += vcc->qos.txtp.max_pcr;
+               break;
+       case ATM_VBR_NRT:
++#if 0         /* Disabled to keep atm_qos struct untouched */
+               port->tx_used_cell_rate += vcc->qos.txtp.scr;
++#endif
+               break;
+       case ATM_UBR_PLUS:
+               port->tx_used_cell_rate += vcc->qos.txtp.min_pcr;
+@@ -1226,7 +1240,9 @@ static void ppe_close(struct atm_vcc *vc
+               port->tx_used_cell_rate -= vcc->qos.txtp.max_pcr;
+               break;
+       case ATM_VBR_NRT:
++#if 0         /* Disabled to keep atm_qos struct untouched */
+               port->tx_used_cell_rate -= vcc->qos.txtp.scr;
++#endif
+               break;
+       case ATM_UBR_PLUS:
+               port->tx_used_cell_rate -= vcc->qos.txtp.min_pcr;
diff --git a/package/kernel/lantiq/vrx518_tc/patches/200-swplat.patch 
b/package/kernel/lantiq/vrx518_tc/patches/200-swplat.patch
index 0d97ec4d5f..cff48a29ef 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
+@@ -613,7 +613,11 @@ static void atm_aca_init(struct atm_priv
        cfg = &priv->tc_priv->cfg;
  
        txin = &param.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
+@@ -635,7 +639,11 @@ static void atm_aca_init(struct atm_priv
                txin->soc_cmlt_cnt_addr);
  
        txout = &param.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
+@@ -657,7 +665,11 @@ static void atm_aca_init(struct atm_priv
                txout->soc_cmlt_cnt_addr);
  
        rxout = &param.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
+@@ -679,7 +691,11 @@ static void atm_aca_init(struct atm_priv
                rxout->soc_cmlt_cnt_addr);
  
        rxin = &param.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
+@@ -1277,7 +1293,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,
+@@ -1343,12 +1359,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..7869293394 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
+@@ -3666,7 +3666,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)
+@@ -4036,7 +4036,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..505cd6184d 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
+@@ -756,7 +756,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,
+@@ -775,7 +776,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,
+@@ -977,7 +979,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..deee3f3ed3 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 <ryazanov....@gmail.com>
 ---
 --- a/dcdp/atm_tc.c
 +++ b/dcdp/atm_tc.c
-@@ -1232,8 +1232,9 @@ static void ppe_close(struct atm_vcc *vc
+@@ -1246,8 +1246,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 <ryazanov....@gmail.com>
                                
        memset(conn, 0, sizeof(*conn));
  
-@@ -2791,24 +2792,26 @@ static void mpoa_setup_sync(struct atm_p
+@@ -2807,24 +2808,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
index c15a4b3ae3..09417c05a4 100644
--- a/target/linux/ipq40xx/patches-6.6/998-lantiq-atm-hacks.patch
+++ b/target/linux/ipq40xx/patches-6.6/998-lantiq-atm-hacks.patch
@@ -20,13 +20,19 @@ Signed-off-by: John Crispin <blo...@openwrt.org>
  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 {
+@@ -155,6 +161,15 @@ 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 */ 
++#if 0
++      /* Used only by Lantiq VRX518 TC driver. No actual users, but break
++       * compatibility with linux-atm tools. So commented out to avoid the
++       * struct size change.
++       */
 +      int             scr;            /* sustained rate in cells per second */
 +      int             mbs;            /* maximum burst size (MBS) in cells */
 +      int             cdv;            /* Cell delay variation */
++#endif
  };
  
  struct atm_qos {
-- 
2.45.2


_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to