Re: [RFC] Reducing size of BLE Security Manager

2017-01-20 Thread Szymon Janc
Hi, On 20 January 2017 at 21:42, will sanfilippo wrote: > Hopefully I am not going to drag this discussion on too long, but I like this > stuff so… > > The cortex-M processors have byte, half-word and word instructions. It will > use the appropriate instruction when you

Re: [RFC] Reducing size of BLE Security Manager

2017-01-20 Thread Szymon Janc
Hi, On 20 January 2017 at 19:14, Christopher Collins wrote: > On Fri, Jan 20, 2017 at 09:45:07AM -0800, will sanfilippo wrote: >> I was referring to C code that accesses a packed structure, not necessarily >> the construction part of it. For example: (and in this example I

Re: [RFC] Reducing size of BLE Security Manager

2017-01-20 Thread Christopher Collins
On Fri, Jan 20, 2017 at 09:45:07AM -0800, will sanfilippo wrote: > I was referring to C code that accesses a packed structure, not necessarily > the construction part of it. For example: (and in this example I am assuming > the processor can access bytes anywhere, 16-bit values on 16-bit

Re: [RFC] Reducing size of BLE Security Manager

2017-01-20 Thread Szymon Janc
Hi Will, On 20 January 2017 at 17:56, will sanfilippo wrote: > I have mixed feelings about packed structures. For processors that cannot > handle unaligned accesses I have always found that they increased code size. > Every access of an element in that structure needs code to

Re: [RFC] Reducing size of BLE Security Manager

2017-01-20 Thread will sanfilippo
I have mixed feelings about packed structures. For processors that cannot handle unaligned accesses I have always found that they increased code size. Every access of an element in that structure needs code to determine the alignment of that element. Sure, they save RAM, so if that is what you

Re: [RFC] Reducing size of BLE Security Manager

2017-01-20 Thread Christopher Collins
On Fri, Jan 20, 2017 at 10:21:16AM +0100, Szymon Janc wrote: > Code is available at [1]. I'm not making it a pull request yet since > I'd like to get some feedback about this approach from others. Also I > still need to get tests passing since SM keys related tests fail now > (and I'm not yet sure

Re: [RFC] Reducing size of BLE Security Manager

2017-01-20 Thread Christopher Collins
Hi Szymon, On Fri, Jan 20, 2017 at 10:21:16AM +0100, Szymon Janc wrote: > Hi, > > I was recently looking on how we could reduce size of SM code. > So my proposal is to change the way PDUs are parsed and constructed. > > Instead of having ble_sm_foo_parse(), ble_sm_foo_write() and

[RFC] Reducing size of BLE Security Manager

2017-01-20 Thread Szymon Janc
Hi, I was recently looking on how we could reduce size of SM code. So my proposal is to change the way PDUs are parsed and constructed. Instead of having ble_sm_foo_parse(), ble_sm_foo_write() and ble_sm_foo_tx() for parsing and constructing PDU byte by byte we could use packed structures for