Holger Hans Peter Freyther wrote:
* The extra msgb_alloc/memcpy to go from primitive to
native is
wasteful. One should re-write the header around the payload.
* The change to introduce the primitives is too big. Otherwise the
above two issues could have been spotted with review. My proposal
is to introduce primitives inside the sysmoBTS code piece by
piece in one primitive per patch.
hi holger,
i started splitting the l1sap implementation into parts. the first part
is just cover the BCCH RTS/REQ messages. these are moved from
osmo-bts-sysmo code to common code. i pushed a new branch where i will
commit each part. see last commit of jolly/l1sap_parts branch.
in this commit i found a solution to convert a l1sap message to l1p
(sysmo-bts) message without memcpy: the l1p structure is not just a
header+payload, but a structure that includes the payload as fixed
element. i needed to expand the headroom and tail of a message
(allocated at l1sap.c), so the l1p structure can be casted over the
existing message. the payload will then be at the right spot inside the
l1p structure. the structure's data around the payload will be cleared.
before the actual casting of structure is done, the l1sap header is
pulled (data points to payload) and the length is trimmed to 0.
push/clear part of the l1p structure that is in front of the actual payload:
temp = l1p->u.phDataReq.msgUnitParam.u8Buffer;
msgb_push(msg, temp - (uint8_t *)l1p);
memset(msg->data, 0, msg->len);
put the actual payload that is already inside message:
msgb_put(msg, len); NOTE: 'len' is the actual lenght
of payload
put/clear the rest of of the structure that is behind the actual payload.
memset(msg->tail, 0, sizeof(*l1p) - msg->len);
msgb_put(msg, sizeof(*l1p) - msg->len);
msg->l1h = msg->data;
regards,
andreas