@@ -753,6 +753,11 @@ struct iccom_packet {
753
753
// transferred to the consumer;
754
754
// false: then message data ownership remains in ICCom,
755
755
// and is immediately discarded after callback invocation.
756
+ //
757
+ // @total_msgs_rcv indicates the total number of the messages received
758
+ // on this channel.
759
+ // @total_consumer_bytes_rcv indicates the total number of consumer
760
+ // bytes received on this channel.
756
761
struct iccom_message_storage_channel
757
762
{
758
763
struct list_head channel_anchor ;
@@ -764,6 +769,9 @@ struct iccom_message_storage_channel
764
769
765
770
void * consumer_callback_data ;
766
771
iccom_msg_ready_callback_ptr_t message_ready_callback ;
772
+
773
+ int64_t total_msgs_rcv ;
774
+ int64_t total_consumer_bytes_rcv ;
767
775
};
768
776
769
777
// Describes the messages storage. Intended to be used to
@@ -1895,6 +1903,9 @@ __iccom_msg_storage_add_channel(struct iccom_message_storage *storage
1895
1903
channel_rec -> consumer_callback_data = NULL ;
1896
1904
channel_rec -> message_ready_callback = NULL ;
1897
1905
1906
+ channel_rec -> total_msgs_rcv = 0 ;
1907
+ channel_rec -> total_consumer_bytes_rcv = 0 ;
1908
+
1898
1909
return channel_rec ;
1899
1910
}
1900
1911
@@ -2329,7 +2340,11 @@ static void __iccom_msg_storage_channel_commit(
2329
2340
if (msg -> uncommitted_length == 0 ) {
2330
2341
continue ;
2331
2342
}
2343
+ channel_rec -> total_consumer_bytes_rcv += msg -> uncommitted_length ;
2332
2344
msg -> uncommitted_length = 0 ;
2345
+ if (msg -> finalized ) {
2346
+ channel_rec -> total_msgs_rcv ++ ;
2347
+ }
2333
2348
}
2334
2349
}
2335
2350
@@ -5719,6 +5734,39 @@ static ssize_t statistics_show(
5719
5734
}
5720
5735
static DEVICE_ATTR_RO (statistics );
5721
5736
5737
+ // Prints info about the current iccom channels.
5738
+ static ssize_t channels_show (
5739
+ struct device * dev , struct device_attribute * attr , char * buf )
5740
+ {
5741
+ ICCOM_CHECK_PTR (buf , return - EINVAL );
5742
+
5743
+ struct iccom_dev * iccom = (struct iccom_dev * )dev_get_drvdata (dev );
5744
+
5745
+ ICCOM_CHECK_DEVICE ("no device provided" , return - ENODEV );
5746
+ ICCOM_CHECK_DEVICE_PRIVATE ("broken device data" , return - ENODEV );
5747
+
5748
+ size_t len = 0 ;
5749
+
5750
+ // need to lock storage to get the info
5751
+ struct iccom_message_storage * storage = & iccom -> p -> rx_messages ;
5752
+ struct iccom_message_storage_channel * channel_rec = NULL ;
5753
+ mutex_lock (& storage -> lock );
5754
+ list_for_each_entry (channel_rec , & storage -> channels_list
5755
+ , channel_anchor ) {
5756
+ len += (size_t )scnprintf (buf + len , PAGE_SIZE - len ,
5757
+ "%d: I: %llu m %llu b\n"
5758
+ , channel_rec -> channel
5759
+ , channel_rec -> total_msgs_rcv
5760
+ , channel_rec -> total_consumer_bytes_rcv
5761
+ );
5762
+ }
5763
+ atomic_set (& storage -> uncommitted_finalized_count , 0 );
5764
+ mutex_unlock (& storage -> lock );
5765
+
5766
+ return len ;
5767
+ }
5768
+ static DEVICE_ATTR_RO (channels );
5769
+
5722
5770
// The size of the data package currently used, in bytes
5723
5771
static ssize_t data_package_size_show (
5724
5772
struct device * dev , struct device_attribute * attr , char * buf )
@@ -5894,6 +5942,7 @@ static DEVICE_ATTR_WO(channels_ctl);
5894
5942
static struct attribute * iccom_dev_attrs [] = {
5895
5943
& dev_attr_transport .attr ,
5896
5944
& dev_attr_statistics .attr ,
5945
+ & dev_attr_channels .attr ,
5897
5946
& dev_attr_channels_ctl .attr ,
5898
5947
& dev_attr_channels_RW .attr ,
5899
5948
& dev_attr_data_package_size .attr ,
0 commit comments