Commit d118fff2 authored by Johan Hedberg's avatar Johan Hedberg Committed by Johan Hedberg
Browse files

Bluetooth: Mesh: Remove unnecessary per-buffer segment context



The friend_cred and new_key information is common for all segments of
a segmented transaction, so it makes sense to store them as part of
struct seg_tx instead of each buffer's user data.

Signed-off-by: default avatarJohan Hedberg <johan.hedberg@intel.com>
parent 9b2a6d48
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -35,9 +35,7 @@ struct bt_mesh_adv {
		/* For transport layer segment sending */
		struct {
			u8_t tx_id;
			u8_t attempts:6,
			     new_key:1,
			     friend_cred:1;
			u8_t attempts;
		} seg;
	};
};
+9 −9
Original line number Diff line number Diff line
@@ -61,8 +61,10 @@ static struct seg_tx {
	struct net_buf          *seg[BT_MESH_TX_SEG_COUNT];
	u64_t                    seq_auth;
	u16_t                    dst;
	u8_t                     seg_n;      /* Last segment index */
	u8_t                     nack_count; /* Number of not acked segments */
	u8_t                     seg_n:5,       /* Last segment index */
				 friend_cred:1, /* Use Friendship creds */
				 new_key:1;     /* New/old key */
	u8_t                     nack_count;    /* Number of unacked segs */
	bt_mesh_cb_t             cb;
	void                    *cb_data;
	struct k_delayed_work    retransmit;    /* Retransmit timer */
@@ -229,10 +231,8 @@ static void seg_tx_send_unacked(struct seg_tx *tx)

		BT_DBG("resending %u/%u", i, tx->seg_n);

		err = bt_mesh_net_resend(tx->sub, seg,
					 BT_MESH_ADV(seg)->seg.new_key,
					 BT_MESH_ADV(seg)->seg.friend_cred,
					 seg_sent);
		err = bt_mesh_net_resend(tx->sub, seg, tx->new_key,
					 tx->friend_cred, seg_sent);
		if (err) {
			BT_ERR("Sending segment failed");
			seg_tx_complete(tx, -EIO);
@@ -295,6 +295,8 @@ static int send_seg(struct bt_mesh_net_tx *net_tx, u8_t aid,
	tx->nack_count = tx->seg_n + 1;
	tx->seq_auth = SEQ_AUTH(BT_MESH_NET_IVI_TX, bt_mesh.seq);
	tx->sub = net_tx->sub;
	tx->new_key = net_tx->sub->kr_flag;
	tx->friend_cred = net_tx->ctx->friend_cred;

	seq_zero = tx->seq_auth & 0x1fff;

@@ -317,8 +319,6 @@ static int send_seg(struct bt_mesh_net_tx *net_tx, u8_t aid,

		BT_MESH_ADV(seg)->seg.tx_id = tx - seg_tx;
		BT_MESH_ADV(seg)->seg.attempts = SEG_RETRANSMIT_ATTEMPTS;
		BT_MESH_ADV(seg)->seg.new_key = net_tx->sub->kr_flag;
		BT_MESH_ADV(seg)->seg.friend_cred = net_tx->ctx->friend_cred;

		net_buf_reserve(seg, BT_MESH_NET_HDR_LEN);