summaryrefslogtreecommitdiffstats
path: root/scripts/basic/Makefile
diff options
context:
space:
mode:
authorTim Harvey <tharvey@gateworks.com>2015-04-08 12:54:56 -0700
committerStefano Babic <sbabic@denx.de>2015-04-22 14:39:11 +0200
commit95069704cdd88c1e0494081056df08b9526b9ae1 (patch)
treefb9f55a11371f97f4230ea15e4d4cef78f05a51f /scripts/basic/Makefile
parent7f14c31bba70ee339c8c730e263a143b869f2828 (diff)
imx: ventana: add DT fixup for GW54xx compatibility with older kernels
Certain older kernels in use by some customers erroneously define a uart3 for GW54xx with a pinmux that conflicts with NAND. This will remove that node to avoid such conflicts. Signed-off-by: Tim Harvey <tharvey@gateworks.com>
Diffstat (limited to 'scripts/basic/Makefile')
0 files changed, 0 insertions, 0 deletions
ref='#n115'>115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275
/*
 *  OpenVPN -- An application to securely tunnel IP networks
 *             over a single UDP port, with support for SSL/TLS-based
 *             session authentication and key exchange,
 *             packet encryption, packet authentication, and
 *             packet compression.
 *
 *  Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License version 2
 *  as published by the Free Software Foundation.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program (see the file COPYING included with this
 *  distribution); if not, write to the Free Software Foundation, Inc.,
 *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

#include "syshead.h"

#ifdef USE_LZO

#include "lzo.h"
#include "error.h"
#include "otime.h"

#include "memdbg.h"

static bool
lzo_adaptive_compress_test (struct lzo_adaptive_compress *ac)
{
  const bool save = ac->compress_state;
  const time_t local_now = now;

  if (!ac->compress_state)
    {
      if (local_now >= ac->next)
	{
	  if (ac->n_total > AC_MIN_BYTES
	      && (ac->n_total - ac->n_comp) < (ac->n_total / (100 / AC_SAVE_PCT)))
	    {
	      ac->compress_state = true;
	      ac->next = local_now + AC_OFF_SEC;
	    }
	  else
	    {
	      ac->next = local_now + AC_SAMP_SEC;
	    }
	  dmsg (D_COMP, "lzo_adaptive_compress_test: comp=%d total=%d", ac->n_comp, ac->n_total);
	  ac->n_total = ac->n_comp = 0;
	}
    }
  else 
    {
      if (local_now >= ac->next)
	{
	  ac->next = local_now + AC_SAMP_SEC;
	  ac->n_total = ac->n_comp = 0;
	  ac->compress_state = false;
	}
    }

  if (ac->compress_state != save)
    dmsg (D_COMP_LOW, "Adaptive compression state %s", (ac->compress_state ? "OFF" : "ON"));

  return !ac->compress_state;
}

static inline void
lzo_adaptive_compress_data (struct lzo_adaptive_compress *ac, int n_total, int n_comp)
{
  ac->n_total += n_total;
  ac->n_comp += n_comp;
}

void lzo_adjust_frame_parameters (struct frame *frame)
{
  /* Leave room for our one-byte compressed/didn't-compress prefix byte. */
  frame_add_to_extra_frame (frame, LZO_PREFIX_LEN);

  /* Leave room for compression buffer to expand in worst case scenario
     where data is totally uncompressible */
  frame_add_to_extra_buffer (frame, LZO_EXTRA_BUFFER (EXPANDED_SIZE(frame)));
}

void
lzo_compress_init (struct lzo_compress_workspace *lzowork, unsigned int flags)
{
  CLEAR (*lzowork);

  lzowork->wmem_size = LZO_WORKSPACE;
  lzowork->flags = flags;

  if (lzo_init () != LZO_E_OK)
    msg (M_FATAL, "Cannot initialize LZO compression library");
  lzowork->wmem = (lzo_voidp) lzo_malloc (lzowork->wmem_size);
  check_malloc_return (lzowork->wmem);
  msg (M_INFO, "LZO compression initialized");
  lzowork->defined = true;
}

void
lzo_compress_uninit (struct lzo_compress_workspace *lzowork)
{
  if (lzowork)
    {
      ASSERT (lzowork->defined);
      lzo_free (lzowork->wmem);
      lzowork->wmem = NULL;
      lzowork->defined = false;
    }
}

static inline bool
lzo_compression_enabled (struct lzo_compress_workspace *lzowork)
{
  if ((lzowork->flags & (LZO_SELECTED|LZO_ON)) == (LZO_SELECTED|LZO_ON))
    {
      if (lzowork->flags & LZO_ADAPTIVE)
	return lzo_adaptive_compress_test (&lzowork->ac);
      else
	return true;
    }
  return false;
}

/* Magic numbers to tell our peer if we compressed or not */
#define YES_COMPRESS 0x66
#define NO_COMPRESS  0xFA

void
lzo_compress (struct buffer *buf, struct buffer work,
	      struct lzo_compress_workspace *lzowork,
	      const struct frame* frame)
{
  lzo_uint zlen = 0;
  int err;
  bool compressed = false;

  ASSERT (lzowork->defined);

  if (buf->len <= 0)
    return;

  /*
   * In order to attempt compression, length must be at least COMPRESS_THRESHOLD,
   * and our adaptive level must give the OK.
   */
  if (buf->len >= COMPRESS_THRESHOLD && lzo_compression_enabled (lzowork))
    {
      ASSERT (buf_init (&work, FRAME_HEADROOM (frame)));
      ASSERT (buf_safe (&work, LZO_EXTRA_BUFFER (PAYLOAD_SIZE (frame))));

      if (!(buf->len <= PAYLOAD_SIZE (frame)))
	{
	  dmsg (D_COMP_ERRORS, "LZO compression buffer overflow");
	  buf->len = 0;
	  return;
	}