diff mbox

[2/5] hw/bt: Convert retry_count to send_count

Message ID 1446078249-10336-3-git-send-email-cyril.bur@au1.ibm.com
State Superseded
Headers show

Commit Message

Cyril Bur Oct. 29, 2015, 12:24 a.m. UTC
It is useful to know if a message has been sent at all, the counter used to
retry sending can be used for this.

Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com>
---
 hw/bt.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

Comments

Alistair Popple Oct. 29, 2015, 1:13 a.m. UTC | #1
Acked-by: Alistair Popple <alistair@popple.id.au>

On Thu, 29 Oct 2015 11:24:06 Cyril Bur wrote:
> It is useful to know if a message has been sent at all, the counter used to
> retry sending can be used for this.
> 
> Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com>
> ---
>  hw/bt.c | 13 +++++++------
>  1 file changed, 7 insertions(+), 6 deletions(-)
> 
> diff --git a/hw/bt.c b/hw/bt.c
> index 15e494f..7266b2f 100644
> --- a/hw/bt.c
> +++ b/hw/bt.c
> @@ -67,7 +67,7 @@
>  /*
>   * Maximum number of times to attempt sending a message before giving up.
>   */
> -#define BT_MAX_RETRY_COUNT 1
> +#define BT_MAX_SEND_COUNT 2
>  
>  #define BT_QUEUE_DEBUG 0
>  
> @@ -106,7 +106,7 @@ struct bt_msg {
>  	struct list_node link;
>  	unsigned long tb;
>  	uint8_t seq;
> -	uint8_t retry_count;
> +	uint8_t send_count;
>  	struct ipmi_msg ipmi_msg;
>  };
>  
> @@ -212,6 +212,7 @@ static void bt_send_msg(struct bt_msg *bt_msg)
>  	for (i = 0; i < ipmi_msg->req_size; i++)
>  		bt_outb(ipmi_msg->data[i], BT_HOST2BMC);
>  
> +	bt_msg->send_count++;
>  	BT_DBG(bt_msg, "Message sent to host");
>  	bt_outb(BT_CTRL_H2B_ATN, BT_CTRL);
>  	bt_set_state(BT_STATE_RESP_WAIT);
> @@ -318,13 +319,13 @@ static void bt_expire_old_msg(uint64_t tb)
>  	bt_msg = list_top(&bt.msgq, struct bt_msg, link);
>  
>  	if (bt_msg && bt_msg->tb > 0 && (bt_msg->tb + BT_MSG_TIMEOUT) < tb) {
> -		if (bt_msg->retry_count < BT_MAX_RETRY_COUNT) {
> +		if (bt_msg->send_count < BT_MAX_SEND_COUNT) {
>  			/* A message timeout is usually due to the BMC
>  			clearing the H2B_ATN flag without actually
>  			doing anything. The data will still be in the
>  			FIFO so just reset the flag.*/
>  			BT_ERR(bt_msg, "Retry sending message");
> -			bt_msg->retry_count++;
> +			bt_msg->send_count++;
>  			bt_msg->tb = tb;
>  			bt_outb(BT_CTRL_H2B_ATN, BT_CTRL);
>  		} else {
> @@ -350,7 +351,7 @@ static void print_debug_queue_info(void)
>  		printed = false;
>  		prlog(PR_DEBUG, "-------- BT Msg Queue --------\n");
>  		list_for_each(&bt.msgq, msg, link) {
> -			BT_DBG(msg, "[]");
> +			BT_DBG(msg, "[ sent %d ]", msg->send_count);
>  		}
>  		prlog(PR_DEBUG, "-----------------------------\n");
>  	} else if (!printed) {
> @@ -432,7 +433,7 @@ static void bt_add_msg(struct bt_msg *bt_msg)
>  {
>  	bt_msg->tb = 0;
>  	bt_msg->seq = ipmi_seq++;
> -	bt_msg->retry_count = 0;
> +	bt_msg->send_count = 0;
>  	bt.queue_len++;
>  	if (bt.queue_len > BT_MAX_QUEUE_LEN) {
>  		/* Maximum queue length exceeded - remove the oldest message
>
diff mbox

Patch

diff --git a/hw/bt.c b/hw/bt.c
index 15e494f..7266b2f 100644
--- a/hw/bt.c
+++ b/hw/bt.c
@@ -67,7 +67,7 @@ 
 /*
  * Maximum number of times to attempt sending a message before giving up.
  */
-#define BT_MAX_RETRY_COUNT 1
+#define BT_MAX_SEND_COUNT 2
 
 #define BT_QUEUE_DEBUG 0
 
@@ -106,7 +106,7 @@  struct bt_msg {
 	struct list_node link;
 	unsigned long tb;
 	uint8_t seq;
-	uint8_t retry_count;
+	uint8_t send_count;
 	struct ipmi_msg ipmi_msg;
 };
 
@@ -212,6 +212,7 @@  static void bt_send_msg(struct bt_msg *bt_msg)
 	for (i = 0; i < ipmi_msg->req_size; i++)
 		bt_outb(ipmi_msg->data[i], BT_HOST2BMC);
 
+	bt_msg->send_count++;
 	BT_DBG(bt_msg, "Message sent to host");
 	bt_outb(BT_CTRL_H2B_ATN, BT_CTRL);
 	bt_set_state(BT_STATE_RESP_WAIT);
@@ -318,13 +319,13 @@  static void bt_expire_old_msg(uint64_t tb)
 	bt_msg = list_top(&bt.msgq, struct bt_msg, link);
 
 	if (bt_msg && bt_msg->tb > 0 && (bt_msg->tb + BT_MSG_TIMEOUT) < tb) {
-		if (bt_msg->retry_count < BT_MAX_RETRY_COUNT) {
+		if (bt_msg->send_count < BT_MAX_SEND_COUNT) {
 			/* A message timeout is usually due to the BMC
 			clearing the H2B_ATN flag without actually
 			doing anything. The data will still be in the
 			FIFO so just reset the flag.*/
 			BT_ERR(bt_msg, "Retry sending message");
-			bt_msg->retry_count++;
+			bt_msg->send_count++;
 			bt_msg->tb = tb;
 			bt_outb(BT_CTRL_H2B_ATN, BT_CTRL);
 		} else {
@@ -350,7 +351,7 @@  static void print_debug_queue_info(void)
 		printed = false;
 		prlog(PR_DEBUG, "-------- BT Msg Queue --------\n");
 		list_for_each(&bt.msgq, msg, link) {
-			BT_DBG(msg, "[]");
+			BT_DBG(msg, "[ sent %d ]", msg->send_count);
 		}
 		prlog(PR_DEBUG, "-----------------------------\n");
 	} else if (!printed) {
@@ -432,7 +433,7 @@  static void bt_add_msg(struct bt_msg *bt_msg)
 {
 	bt_msg->tb = 0;
 	bt_msg->seq = ipmi_seq++;
-	bt_msg->retry_count = 0;
+	bt_msg->send_count = 0;
 	bt.queue_len++;
 	if (bt.queue_len > BT_MAX_QUEUE_LEN) {
 		/* Maximum queue length exceeded - remove the oldest message