net: ieee802154: Add support for requesting ACK on packets
This is meant if only one needs reliability when sending non-TCP packets (as TCP would make is redundant). Change-Id: I7dc605094b422a750424c3498d18f32d809d23a8 Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
This commit is contained in:
parent
b986c7681e
commit
d02fe29616
|
@ -22,6 +22,8 @@
|
|||
#ifndef __IEEE802154_H__
|
||||
#define __IEEE802154_H__
|
||||
|
||||
#include <net/net_mgmt.h>
|
||||
|
||||
/* This not meant to be used by any code but 802.15.4 L2 stack */
|
||||
struct ieee802154_context {
|
||||
uint16_t pan_id;
|
||||
|
@ -29,7 +31,33 @@ struct ieee802154_context {
|
|||
uint8_t sequence;
|
||||
struct nano_sem ack_lock;
|
||||
uint8_t ack_received : 1;
|
||||
uint8_t _unused : 7;
|
||||
uint8_t ack_requested : 1;
|
||||
uint8_t _unused : 6;
|
||||
} __packed;
|
||||
|
||||
|
||||
/* Management part definitions */
|
||||
|
||||
#define _NET_IEEE802154_LAYER NET_MGMT_LAYER_L2
|
||||
#define _NET_IEEE802154_CODE 0x154
|
||||
#define _NET_IEEE802154_BASE (NET_MGMT_IFACE_BIT | \
|
||||
NET_MGMT_LAYER(_NET_IEEE802154_LAYER) |\
|
||||
NET_MGMT_LAYER_CODE(_NET_IEEE802154_CODE))
|
||||
|
||||
enum net_request_ieee802154_cmd {
|
||||
NET_REQUEST_IEEE802154_CMD_SET_ACK = 1,
|
||||
NET_REQUEST_IEEE802154_CMD_UNSET_ACK,
|
||||
};
|
||||
|
||||
|
||||
#define NET_REQUEST_IEEE802154_SET_ACK \
|
||||
(_NET_IEEE802154_BASE | NET_REQUEST_IEEE802154_CMD_SET_ACK)
|
||||
|
||||
NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_IEEE802154_SET_ACK);
|
||||
|
||||
#define NET_REQUEST_IEEE802154_UNSET_ACK \
|
||||
(_NET_IEEE802154_BASE | NET_REQUEST_IEEE802154_CMD_UNSET_ACK)
|
||||
|
||||
NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_IEEE802154_UNSET_ACK);
|
||||
|
||||
#endif /* __IEEE802154_H__ */
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
ccflags-y += -I${srctree}/net/yaip
|
||||
|
||||
obj-$(CONFIG_NET_L2_IEEE802154) += ieee802154.o \
|
||||
ieee802154_frame.o \
|
||||
ieee802154_frame.o
|
||||
|
||||
obj-$(CONFIG_NET_L2_IEEE802154_MGMT) += ieee802154_mgmt.o
|
||||
obj-$(CONFIG_NET_L2_IEEE802154_RADIO_ALOHA) += ieee802154_radio_aloha.o
|
||||
obj-$(CONFIG_NET_L2_IEEE802154_RADIO_CSMA_CA) += ieee802154_radio_csma_ca.o
|
||||
|
||||
|
|
|
@ -248,7 +248,8 @@ uint16_t ieee802154_compute_header_size(struct net_if *iface,
|
|||
return hdr_len;
|
||||
}
|
||||
|
||||
static inline struct ieee802154_fcf_seq *generate_fcf_grounds(uint8_t **p_buf)
|
||||
static inline struct ieee802154_fcf_seq *generate_fcf_grounds(uint8_t **p_buf,
|
||||
uint8_t ack)
|
||||
{
|
||||
struct ieee802154_fcf_seq *fs;
|
||||
|
||||
|
@ -256,7 +257,7 @@ static inline struct ieee802154_fcf_seq *generate_fcf_grounds(uint8_t **p_buf)
|
|||
|
||||
fs->fc.security_enabled = 0;
|
||||
fs->fc.frame_pending = 0;
|
||||
fs->fc.ar = 0;
|
||||
fs->fc.ar = ack;
|
||||
fs->fc.pan_id_comp = 0;
|
||||
fs->fc.reserved = 0;
|
||||
/** We support version 2006 only for now */
|
||||
|
@ -391,7 +392,7 @@ bool ieee802154_create_data_frame(struct net_if *iface,
|
|||
struct ieee802154_frame_params params;
|
||||
struct ieee802154_fcf_seq *fs;
|
||||
|
||||
fs = generate_fcf_grounds(&p_buf);
|
||||
fs = generate_fcf_grounds(&p_buf, ctx->ack_requested);
|
||||
|
||||
fs->fc.frame_type = IEEE802154_FRAME_TYPE_DATA;
|
||||
fs->sequence = ctx->sequence++;
|
||||
|
@ -427,7 +428,7 @@ bool ieee802154_create_ack_frame(struct net_if *iface,
|
|||
return false;
|
||||
}
|
||||
|
||||
fs = generate_fcf_grounds(&p_buf);
|
||||
fs = generate_fcf_grounds(&p_buf, 0);
|
||||
|
||||
fs->fc.frame_type = IEEE802154_FRAME_TYPE_ACK;
|
||||
fs->sequence = seq;
|
||||
|
|
43
net/yaip/l2/ieee802154/ieee802154_mgmt.c
Normal file
43
net/yaip/l2/ieee802154/ieee802154_mgmt.c
Normal file
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
* Copyright (c) 2016 Intel Corporation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#include <net/net_if.h>
|
||||
#include <net/ieee802154.h>
|
||||
|
||||
static int ieee802154_set_ack(uint32_t mgmt_request, struct net_if *iface,
|
||||
void *data, size_t len)
|
||||
{
|
||||
struct ieee802154_context *ctx = net_if_l2_data(iface);
|
||||
|
||||
ARG_UNUSED(data);
|
||||
ARG_UNUSED(len);
|
||||
|
||||
if (mgmt_request == NET_REQUEST_IEEE802154_SET_ACK) {
|
||||
ctx->ack_requested = true;
|
||||
} else if (mgmt_request == NET_REQUEST_IEEE802154_UNSET_ACK) {
|
||||
ctx->ack_requested = false;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
NET_MGMT_REGISTER_REQUEST_HANDLER(NET_REQUEST_IEEE802154_SET_ACK,
|
||||
ieee802154_set_ack);
|
||||
|
||||
NET_MGMT_REGISTER_REQUEST_HANDLER(NET_REQUEST_IEEE802154_UNSET_ACK,
|
||||
ieee802154_set_ack);
|
Loading…
Reference in a new issue