dvb: Add DVBv5 stats properties for Quality of Service
Subsystems (2)
RFC PATCH v8 1/2 dvb: Add DVBv5 stats properties for Quality of Service
The DVBv3 quality parameters are limited on several ways:
- Doesn't provide any way to indicate the used measure, so userspace need to guess how to calculate the measure;
- Only a limited set of stats are supported;
- Can't be called in a way to require them to be filled all at once (atomic reads from the hardware), with may cause troubles on interpreting them on userspace;
- On some OFDM delivery systems, the carriers can be independently modulated, having different properties. Currently, there's no way to report per-layer stats.
To address the above issues, adding a new DVBv5-based stats API.
---
v6: Add DocBook documentation.
v7: Some fixes as suggested by Antti
V8: Documentation fix, compilation fix and name the stats struct,
for its reusage inside the core
TODO:
- Add a driver implementation.
--- Documentation/DocBook/media/dvb/dvbproperty.xml | 97 ++++++++++++++++++++++++- include/uapi/linux/dvb/frontend.h | 83 ++++++++++++++++++++- 2 files changed, 177 insertions(+), 3 deletions(-)
Documentation/DocBook/media/dvb/dvbproperty.xml +96 -1
@@ -7,16 +7,29 @@ the capability ioctls weren't implemented yet via the new way.</para> <para>The typical usage for the <constant>FE_GET_PROPERTY/FE_SET_PROPERTY</constant> API is to replace the ioctl's were the <link linkend="dvb-frontend-parameters"> struct <constant>dvb_frontend_parameters</constant></link> were used.</para> +<section id="dtv-stats"> +<title>DTV stats type</title> +<programlisting> +struct dtv_stats { + __u16 value; + __u8 scale; +} __attribute__ ((packed)); +</programlisting> +</section> <section id="dtv-property"> <title>DTV property type</title> <programlisting> /* Reserved fields should be set to 0 */ + struct dtv_property { __u32 cmd; union { __u32 data; struct { - __u8 data[32]; + union { + __u8 data[32]; + __u16 data[16]; + } __u32 len; __u32 reserved1[3]; void *reserved2;
@@ -850,6 +863,78 @@ enum fe_interleaving { <para>use the special macro LNA_AUTO to set LNA auto</para> </section> </section> + + <section id="frontend-qos-properties"> + <title>Frontend Quality of Service/Statistics indicators</title> + <para>Except for <link linkend="DTV-QOS-ENUM"><constant>DTV_QOS_ENUM</constant></link>, + the values are returned via <constant>dtv_property.stat</constant>.</para> + <para>For most delivery systems, this will return a single value for each parameter.</para> + <para>It should be noticed, however, that new OFDM delivery systems + like ISDB can use different modulation types for each group of carriers. + On such standards, up to 3 groups of statistics can be provided, one + for each carrier group (called "layer" on ISDB). + In order to be consistent with other delivery systems, the first + value at <link linkend="dtv-stats"><constant>dtv_property.stat.dtv_stats</constant></link> array refers to + a global indicator, if any. The other elements of the array represent + each layer, starting from layer A(index 1), layer B (index 2) and so on</para> + <para>The number of filled elements are stored at <constant>dtv_property.stat.len</constant>.</para> + <para>Each element of the <constant>dtv_property.stat.dtv_stats</constant> array consists on two elements:</para> + <itemizedlist mark='opencircle'> + <listitem><para><constant>value</constant> - Value of the measure</para></listitem> + <listitem><para><constant>scale</constant> - Scale for the value. It can be:</para> + <section id = "fecap-scale-params"> + <itemizedlist mark='bullet'> + <listitem><para><constant>FE_SCALE_NOT_AVAILABLE</constant> - If it is not possible to collect a given parameter (could be a transitory or permanent condition)</para></listitem> + <listitem><para><constant>FE_SCALE_DECIBEL</constant> - parameter is a signed value, measured in 0.1 dB</para></listitem> + <listitem><para><constant>FE_SCALE_RELATIVE</constant> - parameter is a unsigned value, where 0 means 0% and 65535 means 100%.</para></listitem> + <listitem><para><constant>FE_SCALE_COUNTER</constant> - parameter is a unsigned value that counts the occurrence of an event, like bit error, block error, or lapsed time.</para></listitem> + </itemizedlist> + </section> + </listitem> + </itemizedlist> + <section id="DTV-QOS-ENUM"> + <title><constant>DTV_QOS_ENUM</constant></title> + <para>A frontend needs to advertise the statistics it provides. This property allows to enumerate all + <link linkend="frontend-qos-properties">DTV QoS statistics</link> that are + supported by a given frontend.</para> + + <para><constant>dtv_property.len</constant> indicates the number of supported + <link linkend="frontend-qos-properties">DTV QoS statistics</link>.</para> + <para><constant>dtv_property.data16</constant> is an 16 bits array of the supported properties.</para> + </section> + <section id="DTV-QOS-SIGNAL-STRENGTH"> + <title><constant>DTV_QOS_SIGNAL_STRENGTH</constant></title> + <para>Indicates the signal strength level at the analog part of the tuner.</para> + </section> + <section id="DTV-QOS-CNR"> + <title><constant>DTV_QOS_CNR</constant></title> + <para>Indicates the signal to noise relation for the main carrier.</para> + + </section> + <section id="DTV-QOS-BIT-ERROR-COUNT"> + <title><constant>DTV_QOS_BIT_ERROR_COUNT</constant></title> + <para>Measures the number of bit errors since the last counter reset.</para> + <para>In order to get the BER (Bit Error Rate) measurement, it should be divided by + <link linkend="DTV-QOS-TOTAL-BITS-COUNT"><constant>DTV_QOS_TOTAL_BITS_COUNT</constant></link>.</para> + </section> + <section id="DTV-QOS-TOTAL-BITS-COUNT"> + <title><constant>DTV_QOS_TOTAL_BITS_COUNT</constant></title> + <para>Measures the amount of bits received since the last <link linkend="DTV-QOS-BIT-ERROR-COUNT"><constant>DTV_QOS_BIT_ERROR_COUNT</constant></link> reset.</para> + </section> + <section id="DTV-QOS-ERROR-BLOCK-COUNT"> + <title><constant>DTV_QOS_ERROR_BLOCK_COUNT</constant></title> + <para>Measures the number of block errors since the last counter reset.</para> + </section> + <section id="DTV-QOS-TOTAL-BLOCKS-COUNT"> + <title><constant>DTV-QOS_TOTAL_BLOCKS_COUNT</constant></title> + <para>Measures the total number of blocks since the last + <link linkend="DTV-QOS-ERROR-BLOCK-COUNT"><constant>DTV_QOS_ERROR_BLOCK_COUNT</constant></link> reset.</para> + <para>It can be used to calculate the PER indicator, by dividing + <link linkend="DTV-QOS-ERROR-BLOCK-COUNT"><constant>DTV_QOS_ERROR_BLOCK_COUNT</constant></link> + by <link linkend="DTV-QOS-TOTAL-BLOCKS-COUNT"><constant>DTV-QOS-TOTAL-BLOCKS-COUNT</constant></link>.</para> + </section> + </section> + <section id="frontend-property-terrestrial-systems"> <title>Properties used on terrestrial delivery systems</title> <section id="dvbt-params">
@@ -871,6 +956,7 @@ enum fe_interleaving { <listitem><para><link linkend="DTV-HIERARCHY"><constant>DTV_HIERARCHY</constant></link></para></listitem> <listitem><para><link linkend="DTV-LNA"><constant>DTV_LNA</constant></link></para></listitem> </itemizedlist> + <para>In addition, the <link linkend="frontend-qos-properties">DTV QoS statistics</link> are also valid.</para> </section> <section id="dvbt2-params"> <title>DVB-T2 delivery system</title>
@@ -895,6 +981,7 @@ enum fe_interleaving { <listitem><para><link linkend="DTV-STREAM-ID"><constant>DTV_STREAM_ID</constant></link></para></listitem> <listitem><para><link linkend="DTV-LNA"><constant>DTV_LNA</constant></link></para></listitem> </itemizedlist> + <para>In addition, the <link linkend="frontend-qos-properties">DTV QoS statistics</link> are also valid.</para> </section> <section id="isdbt"> <title>ISDB-T delivery system</title>
@@ -948,6 +1035,7 @@ enum fe_interleaving { <listitem><para><link linkend="DTV-ISDBT-LAYER-SEGMENT-COUNT"><constant>DTV_ISDBT_LAYERC_SEGMENT_COUNT</constant></link></para></listitem> <listitem><para><link linkend="DTV-ISDBT-LAYER-TIME-INTERLEAVING"><constant>DTV_ISDBT_LAYERC_TIME_INTERLEAVING</constant></link></para></listitem> </itemizedlist> + <para>In addition, the <link linkend="frontend-qos-properties">DTV QoS statistics</link> are also valid.</para> </section> <section id="atsc-params"> <title>ATSC delivery system</title>
@@ -961,6 +1049,7 @@ enum fe_interleaving { <listitem><para><link linkend="DTV-MODULATION"><constant>DTV_MODULATION</constant></link></para></listitem> <listitem><para><link linkend="DTV-BANDWIDTH-HZ"><constant>DTV_BANDWIDTH_HZ</constant></link></para></listitem> </itemizedlist> + <para>In addition, the <link linkend="frontend-qos-properties">DTV QoS statistics</link> are also valid.</para> </section> <section id="atscmh-params"> <title>ATSC-MH delivery system</title>
@@ -988,6 +1077,7 @@ enum fe_interleaving { <listitem><para><link linkend="DTV-ATSCMH-SCCC-CODE-MODE-C"><constant>DTV_ATSCMH_SCCC_CODE_MODE_C</constant></link></para></listitem> <listitem><para><link linkend="DTV-ATSCMH-SCCC-CODE-MODE-D"><constant>DTV_ATSCMH_SCCC_CODE_MODE_D</constant></link></para></listitem> </itemizedlist> + <para>In addition, the <link linkend="frontend-qos-properties">DTV QoS statistics</link> are also valid.</para> </section> <section id="dtmb-params"> <title>DTMB delivery system</title>
@@ -1007,6 +1097,7 @@ enum fe_interleaving { <listitem><para><link linkend="DTV-INTERLEAVING"><constant>DTV_INTERLEAVING</constant></link></para></listitem> <listitem><para><link linkend="DTV-LNA"><constant>DTV_LNA</constant></link></para></listitem> </itemizedlist> + <para>In addition, the <link linkend="frontend-qos-properties">DTV QoS statistics</link> are also valid.</para> </section> </section> <section id="frontend-property-cable-systems">
@@ -1028,6 +1119,7 @@ enum fe_interleaving { <listitem><para><link linkend="DTV-INNER-FEC"><constant>DTV_INNER_FEC</constant></link></para></listitem> <listitem><para><link linkend="DTV-LNA"><constant>DTV_LNA</constant></link></para></listitem> </itemizedlist> + <para>In addition, the <link linkend="frontend-qos-properties">DTV QoS statistics</link> are also valid.</para> </section> <section id="dvbc-annex-b-params"> <title>DVB-C Annex B delivery system</title>
@@ -1043,6 +1135,7 @@ enum fe_interleaving { <listitem><para><link linkend="DTV-INVERSION"><constant>DTV_INVERSION</constant></link></para></listitem> <listitem><para><link linkend="DTV-LNA"><constant>DTV_LNA</constant></link></para></listitem> </itemizedlist> + <para>In addition, the <link linkend="frontend-qos-properties">DTV QoS statistics</link> are also valid.</para> </section> </section> <section id="frontend-property-satellital-systems">
@@ -1062,6 +1155,7 @@ enum fe_interleaving { <listitem><para><link linkend="DTV-VOLTAGE"><constant>DTV_VOLTAGE</constant></link></para></listitem> <listitem><para><link linkend="DTV-TONE"><constant>DTV_TONE</constant></link></para></listitem> </itemizedlist> + <para>In addition, the <link linkend="frontend-qos-properties">DTV QoS statistics</link> are also valid.</para> <para>Future implementations might add those two missing parameters:</para> <itemizedlist mark='opencircle'> <listitem><para><link linkend="DTV-DISEQC-MASTER"><constant>DTV_DISEQC_MASTER</constant></link></para></listitem>
@@ -1077,6 +1171,7 @@ enum fe_interleaving { <listitem><para><link linkend="DTV-ROLLOFF"><constant>DTV_ROLLOFF</constant></link></para></listitem> <listitem><para><link linkend="DTV-STREAM-ID"><constant>DTV_STREAM_ID</constant></link></para></listitem> </itemizedlist> + <para>In addition, the <link linkend="frontend-qos-properties">DTV QoS statistics</link> are also valid.</para> </section> <section id="turbo-params"> <title>Turbo code delivery system</title>
include/uapi/linux/dvb/frontend.h +81 -2
101 lines not on this page · raw message
Signature · 1 line
1.7.11.7
RFC PATCH v8 2/2 dvb: the core logic to handle the DVBv5 QoS properties
Add the logic to poll, reset counters and report the QoS stats to the end user.
The idea is that the core will periodically poll the frontend for the stats. The frontend may return -EBUSY, if the previous collect didn't finish, or it may fill the cached data.
The value returned to the end user is always the cached data.
--- drivers/media/dvb-core/dvb_frontend.c | 36 +++++++++++++++++++++++++++++++++++ drivers/media/dvb-core/dvb_frontend.h | 12 ++++++++++++ 2 files changed, 48 insertions(+)
drivers/media/dvb-core/dvb_frontend.c +36 -0
@@ -260,6 +260,9 @@ static int dvb_frontend_get_event(struct dvb_frontend *fe,return ret; } +if (fe->ops.get_qos_stats) + fe->ops.get_qos_stats (fe); +mutex_lock (&events->mtx); *event = events->events[events->eventr]; events->eventr = (events->eventr +1 ) %MAX_EVENT ;
@@ -1053,6 +1056,15 @@ static struct dtv_cmds_h dtv_cmds[DTV_MAX_COMMAND + 1] = {_DTV_CMD (DTV_ATSCMH_SCCC_CODE_MODE_B ,0 ,0 ),_DTV_CMD (DTV_ATSCMH_SCCC_CODE_MODE_C ,0 ,0 ),_DTV_CMD (DTV_ATSCMH_SCCC_CODE_MODE_D ,0 ,0 ), + +/* Statistics API */ +_DTV_CMD (DTV_QOS_ENUM ,0 ,0 ), +_DTV_CMD (DTV_QOS_SIGNAL_STRENGTH ,0 ,0 ), +_DTV_CMD (DTV_QOS_CNR ,0 ,0 ), +_DTV_CMD (DTV_QOS_BIT_ERROR_COUNT ,0 ,0 ), +_DTV_CMD (DTV_QOS_TOTAL_BITS_COUNT ,0 ,0 ), +_DTV_CMD (DTV_QOS_ERROR_BLOCK_COUNT ,0 ,0 ), + _DTV_CMD(DTV_QOS_TOTAL_BLOCKS_COUNT, 0, 0), };static void dtv_property_dump (struct dvb_frontend *fe,struct dtv_property *tvp)
@@ -1443,6 +1455,25 @@ static int dtv_property_process_get(struct dvb_frontend *fe, tvp->u.data = c->lna;break ; +/* Fill quality measures */ +case DTV_QOS_SIGNAL_STRENGTH : + tvp->u.st = c->strength; +break ; +case DTV_QOS_CNR : + tvp->u.st = c->cnr; +break ; +case DTV_QOS_BIT_ERROR_COUNT : + tvp->u.st = c->bit_error; +break ; +case DTV_QOS_TOTAL_BITS_COUNT : + tvp->u.st = c->bit_count; +break ; +case DTV_QOS_ERROR_BLOCK_COUNT : + tvp->u.st = c->block_error; +break ; +case DTV_QOS_TOTAL_BLOCKS_COUNT : + tvp->u.st = c->block_count; +break ;default :return -EINVAL ; }
@@ -1705,6 +1736,8 @@ static int dtv_property_process_set(struct dvb_frontend *fe,break ;case DTV_DELIVERY_SYSTEM : r =set_delivery_system (fe, tvp->u.data); +if (r >=0 && fe->ops.reset_qos_counters) + fe->ops.reset_qos_counters (fe);break ;case DTV_VOLTAGE : c->voltage = tvp->u.data;
@@ -2305,6 +2338,9 @@ static int dvb_frontend_ioctl_legacy(struct file *file,if (err)break ; err =dtv_set_frontend (fe); +if (err >=0 && fe->ops.reset_qos_counters) + fe->ops.reset_qos_counters (fe); +break ;case FE_GET_EVENT : err =dvb_frontend_get_event (fe, parg, file->f_flags);
drivers/media/dvb-core/dvb_frontend.h +12 -0
@@ -315,6 +315,10 @@ struct dvb_frontend_ops {int (*set_property)(struct dvb_frontend * fe,struct dtv_property * tvp);int (*get_property)(struct dvb_frontend * fe,struct dtv_property * tvp); + +/* QoS statistics callbacks */ +int (*get_qos_stats)(struct dvb_frontend *fe); +int (*reset_qos_counters)(struct dvb_frontend *fe); };#ifdef __DVB_CORE__
@@ -393,6 +397,14 @@ struct dtv_frontend_properties {u8 atscmh_sccc_code_mode_d;u32 lna; + +/* QoS statistics data */ +struct dtv_fe_stats strength; +struct dtv_fe_stats cnr; +struct dtv_fe_stats bit_error; +struct dtv_fe_stats bit_count; +struct dtv_fe_stats block_error; +struct dtv_fe_stats block_count; };struct dvb_frontend {
Signature · 1 line
1.7.11.7
Re: [PATCH RFCv8 2/2] dvb: the core logic to handle the DVBv5 QoS properties
Em Mon, 7 Jan 2013 16:44:15 -0200
Mauro Carvalho Chehab <[email protected]> escreveu:
Quoted 9 lines
Add the logic to poll, reset counters and report the QoS stats to the end user.
The idea is that the core will periodically poll the frontend for the stats. The frontend may return
-EBUSY, if the previous collect didn't finish, or it may fill the cached data.The value returned to the end user is always the cached data.
It is probably better to have a routine to reset the counters, and do the cache cleanup there, instead duplicating it on each frontend driver.
So, I'll amend the following driver on my version. I won't be posting a v9 just due to that. My intention is to post v9 together with a driver's code.
Regards,
Mauro
drivers/media/dvb-core/dvb_frontend.c +23 -4
@@ -1677,6 +1677,25 @@ static int set_delivery_system(struct dvb_frontend *fe, u32 desired_system)return 0 ; } +static int reset_qos_counters (struct dvb_frontend *fe) +{ +struct dtv_frontend_properties *c = &fe->dtv_property_cache; + +/* Reset QoS cache */ + +memset (&c->strength,0 ,sizeof (c->strength)); +memset (&c->cnr,0 ,sizeof (c->cnr)); +memset (&c->bit_error,0 ,sizeof (c->bit_error)); +memset (&c->block_error,0 ,sizeof (c->block_error)); +memset (&c->block_count,0 ,sizeof (c->block_count)); + +/* Call frontend reset counter method, if available */ +if (fe->ops.reset_qos_counters) +return fe->ops.reset_qos_counters (fe); + +return 0 ; +} +static int dtv_property_process_set (struct dvb_frontend *fe,struct dtv_property *tvp,struct file *file)
@@ -1736,8 +1755,8 @@ static int dtv_property_process_set(struct dvb_frontend *fe,break ;case DTV_DELIVERY_SYSTEM : r =set_delivery_system (fe, tvp->u.data); -if (r >=0 && fe->ops.reset_qos_counters) - fe->ops.reset_qos_counters (fe); +if (r >=0 ) +reset_qos_counters (fe);break ;case DTV_VOLTAGE : c->voltage = tvp->u.data;
@@ -2338,8 +2357,8 @@ static int dvb_frontend_ioctl_legacy(struct file *file,if (err)break ; err =dtv_set_frontend (fe); -if (err >=0 && fe->ops.reset_qos_counters) - fe->ops.reset_qos_counters (fe); +if (err >=0 ) +reset_qos_counters (fe);break ;case FE_GET_EVENT :
Signature · 2 lines
Cheers, Mauro