Commit 06adfc30 authored by Federico Vaga's avatar Federico Vaga

kernel: add HMQ message counter

Signed-off-by: Federico Vaga's avatarFederico Vaga <federico.vaga@cern.ch>
parent ab8aeafe
......@@ -485,6 +485,7 @@ static int trtl_probe_hmq(struct trtl_dev *trtl, unsigned int slot,
return err;
hmq->stats.count = 0;
hmq->buf.ptr_w = 0;
hmq->buf.ptr_r = 0;
hmq->buf.size = hmq_default_buf_size;
......
......@@ -77,6 +77,13 @@ struct mturtle_hmq_buffer {
};
/**
* Collection of HMQ statistics
*/
struct trtl_hmq_stats {
unsigned int count; /**< number of messages passed throught the HMQ */
};
/**
* It describe the status of a HMQ slot
*/
......@@ -108,6 +115,8 @@ struct trtl_hmq {
unsigned int max_depth; /**< maximum buffer queue length (HW) */
struct mturtle_hmq_buffer buf; /**< Circular buffer */
struct trtl_hmq_stats stats;
};
/**
......
......@@ -286,6 +286,20 @@ static ssize_t trtl_store_share(struct device *dev,
return count;
}
/**
* It returns the maximum number bytes per message
*/
static ssize_t trtl_show_total(struct device *dev,
struct device_attribute *attr,
char *buf)
{
struct trtl_hmq *hmq = to_trtl_hmq(dev);
return sprintf(buf, "%d\n", hmq->stats.count);
}
DEVICE_ATTR(full, S_IRUGO, trtl_show_full, NULL);
DEVICE_ATTR(empty, S_IRUGO, trtl_show_empty, NULL);
DEVICE_ATTR(count_hw, S_IRUGO, trtl_show_count, NULL);
......@@ -295,6 +309,7 @@ DEVICE_ATTR(count_max_hw, S_IRUGO, trtl_show_count_max_hw, NULL);
DEVICE_ATTR(width_max, S_IRUGO, trtl_show_width_max, NULL);
DEVICE_ATTR(shared_by_users, (S_IRUGO | S_IWUSR | S_IWGRP | S_IWOTH),
trtl_show_share, trtl_store_share);
DEVICE_ATTR(total_messages, S_IRUGO, trtl_show_total, NULL);
static struct attribute *trtl_hmq_attr[] = {
&dev_attr_full.attr,
......@@ -304,6 +319,7 @@ static struct attribute *trtl_hmq_attr[] = {
&dev_attr_count_max_hw.attr,
&dev_attr_width_max.attr,
&dev_attr_shared_by_users.attr,
&dev_attr_total_messages.attr,
NULL,
};
......@@ -544,6 +560,8 @@ static int trtl_message_push(struct trtl_hmq *hmq, void *buf,
fmc_writel(fmc, MQUEUE_CMD_READY | ((size / 4) & 0xFF),
hmq->base_sr + MQUEUE_SLOT_COMMAND);
hmq->stats.count++;
return 0;
}
......@@ -931,6 +949,8 @@ static void trtl_irq_handler_output(struct trtl_hmq *hmq)
fmc_writel(fmc, MQUEUE_CMD_DISCARD, hmq->base_sr + MQUEUE_SLOT_COMMAND);
spin_unlock_irqrestore(&hmq->lock, flags);
hmq->stats.count++;
/* If we are waiting a synchronous answer on this HMQ check */
if ((hmq->flags & TRTL_FLAG_HMQ_SYNC_WAIT) &&
hmq->waiting_seq == buffer[1]) { /* seq number always position 1 */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment